Skip to content

Commit

Permalink
refactor(folders): structure
Browse files Browse the repository at this point in the history
  • Loading branch information
slapshin committed May 2, 2023
1 parent f15b61a commit 5bb51bd
Show file tree
Hide file tree
Showing 185 changed files with 95 additions and 184 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ jobs:
env:
APP_TEST_IMAGE: ${{ env.TEST_IMAGE_NAME }}
run: |
docker-compose -f ci/docker-compose.yml up --exit-code-from app
docker-compose -f devops/ci/docker-compose.yml up --exit-code-from app
build:
runs-on: ubuntu-20.04
Expand Down Expand Up @@ -130,9 +130,6 @@ jobs:
type=sha,priority=300
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}
- name: Update .dockerignore
run: cat docker/.dockerignore.production >> .dockerignore

- name: Build production and push Docker image
uses: docker/build-push-action@v2
with:
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -159,4 +159,5 @@ cython_debug/
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
.idea/
server/settings/environments/development.py
pytest.ini
pytest.ini
run
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ repos:
- id: polint
name: polint
language: system
entry: poetry run polint -i location,unsorted,untranslated locale
entry: poetry run polint -i location,unsorted,untranslated src/locale
pass_filenames: false
- id: dennis
name: dennis
language: system
entry: poetry run dennis-cmd lint --errorsonly locale
entry: poetry run dennis-cmd lint --errorsonly src/locale
pass_filenames: false
26 changes: 13 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,45 +1,45 @@
# -- poetry --

poetry-install:
@poetry install --remove-untracked
poetry install --remove-untracked

# -- code --

lint:
black --check .
mypy .
flake8 .
DJANGO_ENV=build python manage.py makemigrations --dry-run --check
DJANGO_ENV=build python src/manage.py makemigrations --dry-run --check
xenon --max-absolute A \
--max-modules A \
--max-average A \
--exclude server/apps/core/graphql/fields/query_connection.py \
server
--exclude src/apps/core/graphql/fields/query_connection.py \
src
poetry check
pip check
# safety check --bare --full-report -i 39462
polint -i location,unsorted locale
dennis-cmd lint --errorsonly locale
polint -i location,unsorted src/locale
dennis-cmd lint --errorsonly src/locale

test:
@pytest
pytest

# -- django --

make-messages:
@python manage.py makemessages --ignore=.venv/* -l en --no-location
python src/manage.py makemessages -l en --no-location

compile-messages:
@python manage.py compilemessages
python src/manage.py compilemessages

# -- pre-commit --

pre-commit:
@pre-commit
pre-commit

pre-commit-install:
@pre-commit install
@pre-commit install --hook-type commit-msg
pre-commit install
pre-commit install --hook-type commit-msg

pre-commit-update:
@pre-commit autoupdate
pre-commit autoupdate
File renamed without changes.
24 changes: 11 additions & 13 deletions docker/Dockerfile → devops/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,15 @@ RUN apt-get update \

FROM base as production

ARG APP_VERSION

RUN groupadd --system --gid 10001 app \
&& useradd --system --uid 10001 --no-log-init -g app app

COPY . .
COPY devops/docker/server .
COPY devops/docker/nginx/* /etc/nginx
COPY ./src ./src

RUN export DJANGO_ENV=build \
&& python manage.py collectstatic --noinput --verbosity 0 \
&& python manage.py compilemessages \
&& cp docker/nginx/* /etc/nginx \
&& python src/manage.py collectstatic --noinput --verbosity 0 \
&& python src/manage.py compilemessages \
&& groupadd --system --gid 10001 app \
&& useradd --system --uid 10001 --no-log-init -g app app \
&& chmod -R 755 /app \
&& mkdir /var/run/app \
&& mkdir /var/run/nginx \
Expand All @@ -61,12 +59,11 @@ RUN export DJANGO_ENV=build \
&& ln -sf /dev/stderr /var/log/nginx/error.log


ENV DJANGO_ENV=production \
APP_VERSION=$APP_VERSION
ENV DJANGO_ENV=production

USER app

CMD ["/bin/bash", "docker/server/backend.sh"]
CMD ["make", "server"]

# ---

Expand All @@ -77,4 +74,5 @@ RUN poetry install --no-interaction --no-ansi
COPY . .

RUN export DJANGO_ENV=build \
&& python manage.py compilemessages
&& python src/manage.py compilemessages

12 changes: 1 addition & 11 deletions docker/nginx/nginx.conf → devops/docker/nginx/nginx.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
worker_processes auto;
worker_processes auto;

pid /var/run/nginx/pid;

Expand All @@ -21,14 +21,9 @@ http {
access_log /var/run/nginx/access.log;
error_log /var/run/nginx/errors.log;

upstream django {
server unix:/var/run/app/uwsgi.sock;
}

server {
listen 8080 default_server;
charset utf-8;
client_max_body_size 75M;

location /static/ {
expires max;
Expand All @@ -39,10 +34,5 @@ http {
expires max;
root /var/www;
}

location / {
include /etc/nginx/uwsgi_params;
uwsgi_pass django;
}
}
}
30 changes: 30 additions & 0 deletions devops/docker/server/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
CPU_COUNT = $(shell nproc)

GUNICORN_WORKERS_COUNT ?= ${CPU_COUNT}
CELERY_CONCURRENCY ?= ${CPU_COUNT}

.PHONY: server
server:
@python src/manage.py migrate
@gunicorn src.asgi:application \
-k uvicorn.workers.UvicornWorker \
--bind 0.0.0.0:8000

.PHONY: celery-beat
celery-beat:
@rm -f /var/run/app/celerybeat.pid
@celery -A src.celery_app beat \
-s /var/run/app/celerybeat.schedule \
--pidfile /var/run/app/celerybeat.pid

.PHONY: celery-worker
celery-worker:
@celery -A src.celery_app worker --concurrency ${CELERY_CONCURRENCY}

.PHONY: flower
flower:
@celery -A src.celery_app flower --url_prefix=admin/flower

.PHONY: static
static:
@nginx -g 'daemon off;'
1 change: 0 additions & 1 deletion docker/.dockerignore.production

This file was deleted.

16 changes: 0 additions & 16 deletions docker/nginx/uwsgi_params

This file was deleted.

9 changes: 0 additions & 9 deletions docker/server/backend.sh

This file was deleted.

7 changes: 0 additions & 7 deletions docker/server/celery_beat.sh

This file was deleted.

16 changes: 0 additions & 16 deletions docker/server/celery_worker.sh

This file was deleted.

8 changes: 0 additions & 8 deletions docker/server/flower.sh

This file was deleted.

9 changes: 2 additions & 7 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description = ""
authors = ["Lapshin Stanislav"]

[tool.poetry.dependencies]
python = "^3.10"
python = "^3.11"
python-decouple = "*"
psycopg2-binary = "*"
pymemcache = "*"
Expand Down
42 changes: 0 additions & 42 deletions scripts/lint.sh

This file was deleted.

6 changes: 0 additions & 6 deletions server/__init__.py

This file was deleted.

Loading

0 comments on commit 5bb51bd

Please sign in to comment.