Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Создать CD и добавить Docker #3

Merged
merged 6 commits into from
Feb 15, 2024

Conversation

blakkheart
Copy link
Collaborator

@blakkheart blakkheart commented Feb 15, 2024

Всем привет!

Было сделано:

  1. Добавил CD в экшенах, проверить сможем, когда запушим в мейн
  2. Добавил Докер файлы для бекенда (с poetry) и для nginx + докер компоуз. Локально проверил - сервер запускается, БД работает, к админке есть доступ
  3. Добавил пакеты в poetry - gynicorn для сервера и psycopg2 для PostgreSQL. Поменял немного .env (в примере отобразил)

Чуток изменил CI файл, чтобы перестал отваливаться, и добавил настройки для pytest-django, иначе он не находил проект.

@blakkheart blakkheart added the enhancement New feature or request label Feb 15, 2024
@blakkheart blakkheart changed the title added cd git action and dockerfiles for backend and nginx Создать CD и добавить Docker Feb 15, 2024
@VladislavYar
Copy link
Collaborator

👍

Copy link
Collaborator

@NECROshizo NECROshizo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Крутой ПР! Интересные решения. Но вопросы еще будут)

@@ -0,0 +1,27 @@
FROM python:3.11
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Очень нравится этот Dockerfile, но все же нам нужно будет решить оставляем ли requrement . А еще вопрос почему не slim

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://hub.docker.com/_/python

В доке говорят, что лучше использовать дефолт, если нет ограничений по месту
У нас, вроде, пока про оптимизацию речь не идет :)
Можно отложить вопрос, думаю, до второго релиза


WORKDIR /app
COPY ./poetry.lock ./pyproject.toml /app/
RUN poetry install $(test "$DJANGO_ENV" == production && echo "--only=main") --no-interaction --no-ansi
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тут у нас разделены среды и тут нужен ещё ключ --no-dev, чтобы не ставить ruff, pytest b pre-commit

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тут согласен, пропустил данный ключ
Отличное замечание

@@ -0,0 +1,32 @@
version: '3'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

тут вопрос с версией, последняя 3.8 (3.9 как схема) вроде,

@@ -0,0 +1,32 @@
version: '3'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тот же вопрос. Ну и healthcheck впишется. Да и для большей изоляции наверно стоит добавить networks ещё

@@ -0,0 +1,4 @@
[pytest]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Вот с перемещение pyproject.toml там тоже остались настройки pytest

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

о, это там хранится, не знал
можно тогда переписать пути в пайпроджект и удалить конфиг пайтеста

@@ -3,4 +3,4 @@

@pytest.mark.django_db # TODO: тест для проверки пре коммита | удалить как будут тесты
def test_testings():
assert 1 == 1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

я не знаю как так получилось (⁄ ⁄•⁄ω⁄•⁄ ⁄)

docstring-code-format = true


[tool.pytest.ini_options]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Вот он не нужен, раз перемещен.

uses: actions/checkout@v3
- name: Set up Docker Buildbox
uses: docker/setup-buildx-action@v2
- name: Login to Docker
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А не рассматривал хранить сборки в GitHub Packages. Вариант интересный чтобы сборку было сразу видно в репозитории github`a

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не сталкивался, но можно, вай нот

@@ -1,8 +1,81 @@
# name: Deployment
name: Workflow For Build and Deploy
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А не проверял его прямо на сервере?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Пока нет, на выходных собирался сделать

@blakkheart blakkheart merged commit 3e55989 into develop Feb 15, 2024
2 checks passed
@blakkheart blakkheart assigned blakkheart and unassigned Luna-luns Feb 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants