diff --git a/Caddyfile.dev b/Caddyfile.dev deleted file mode 100644 index ca10290..0000000 --- a/Caddyfile.dev +++ /dev/null @@ -1,26 +0,0 @@ -http://project.localhost { - reverse_proxy gulp:3000 -} - -http://django.localhost { - - root * /usr/src/app/ - encode gzip zstd - - @notStatic { - not path /static/* /media/* - } - - reverse_proxy @notStatic django:8000 - - file_server /static/* - file_server /media/* -} - -http://gulp-socket.localhost { - reverse_proxy gulp:3001 -} - -http://webmail.localhost { - reverse_proxy mailhog:8025 -} diff --git a/Caddyfile.pro b/Caddyfile.pro deleted file mode 100644 index 3ea662e..0000000 --- a/Caddyfile.pro +++ /dev/null @@ -1,11 +0,0 @@ -https://project.com - -root * /usr/src/app/ - -@notStatic { - not path /static/* /media/* -} - -reverse_proxy @notStatic django:8000 - -file_server diff --git a/asgi.py b/asgi.py deleted file mode 100644 index 872bba4..0000000 --- a/asgi.py +++ /dev/null @@ -1,11 +0,0 @@ -import os - -os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings") -import django - -django.setup() - -from channels.routing import ProtocolTypeRouter - - -application = ProtocolTypeRouter({}) diff --git a/compose.yaml b/compose.yaml new file mode 100644 index 0000000..6ec9329 --- /dev/null +++ b/compose.yaml @@ -0,0 +1,58 @@ +services: + + postgresql: + image: postgres:16 + container_name: ${PROJECT_NAME}-postgresql + restart: ${RESTART_POLICY} + env_file: .env + environment: + POSTGRES_USER: ${DB_USER} + POSTGRES_PASSWORD: ${DB_PASSWORD} + POSTGRES_DB: ${DB_NAME} + expose: + - 5432 + + django: + build: + context: ./ + dockerfile: ./Dockerfiles/django/Dockerfile + container_name: ${PROJECT_NAME}-django + restart: ${RESTART_POLICY} + entrypoint: /django-launcher.sh + volumes: + - .:/usr/src/app/ + env_file: .env + expose: + - 8000 + depends_on: + - postgresql + - redis + + nginx: + image: nginx:alpine + restart: ${RESTART_POLICY} + env_file: .env + ports: + - 8000:80 + volumes: + - ./static:/var/www/static + - ./media:/var/www/media + - ./nginx.conf:/etc/nginx/nginx.conf + depends_on: + - django + + redis: + image: redis:alpine + restart: ${RESTART_POLICY} + container_name: ${PROJECT_NAME}-redis + env_file: .env + expose: + - ${REDIS_PORT} + + mailhog: + image: mailhog/mailhog:latest + restart: ${RESTART_POLICY} + container_name: ${PROJECT_NAME}-mailhog + env_file: .env + expose: + - 1025 diff --git a/docker-compose.yaml b/docker-compose.yaml deleted file mode 100644 index 538940b..0000000 --- a/docker-compose.yaml +++ /dev/null @@ -1,90 +0,0 @@ -version: '3.8' - -services: - - postgresql: - image: postgres - container_name: ${PROJECT_NAME}-postgresql - restart: "no" - environment: - POSTGRES_USER: ${DB_USER} - POSTGRES_PASSWORD: ${DB_PASSWORD} - POSTGRES_DB: ${DB_NAME} - ports: - - ${DB_PORT}:5432 - networks: - default: - - django: - build: - context: ./ - dockerfile: ./Dockerfiles/django/Dockerfile - container_name: ${PROJECT_NAME}-django - restart: "no" - entrypoint: /django-launcher.sh - volumes: - - .:/usr/src/app/ - env_file: - - .env - expose: - - 8000 - depends_on: - - postgresql - links: - - redis - networks: - default: - - caddy: - image: caddy:alpine - container_name: ${PROJECT_NAME}-caddy - restart: "no" - ports: - - ${CADDY_PORT_HTTP}:80 - - ${CADDY_PORT_HTTPS}:443 - volumes: - - ./Caddyfile.dev:/etc/caddy/Caddyfile - - ./caddy_data:/data - - .:/usr/src/app/ - depends_on: - - django - networks: - default: - aliases: - - django.localhost - - redis: - image: redis:alpine - container_name: ${PROJECT_NAME}-redis - restart: "no" - expose: - - ${REDIS_PORT} - networks: - default: - - mailhog: - image: mailhog/mailhog:latest - container_name: ${PROJECT_NAME}-mailhog - restart: "no" - expose: - - 1025 - networks: - default: - - gulp: - build: - context: ./ - dockerfile: ./Dockerfiles/gulp/Dockerfile - container_name: ${PROJECT_NAME}-gulp - entrypoint: gulp dev - restart: "no" - expose: - - 3000 - - 3001 - volumes: - - .:/usr/src/app/ - - /usr/src/app/node_modules - depends_on: - - caddy - networks: - default: \ No newline at end of file diff --git a/env.example b/env.example index 61af411..ff3fa8c 100644 --- a/env.example +++ b/env.example @@ -1,4 +1,5 @@ PROJECT_NAME=project +RESTART_POLICY="no" # Django DEBUG=True @@ -16,11 +17,9 @@ HCAPTCHA_ENABLED=False HCAPTCHA_SECRET_KEY=0x0000000000000000000000000000000000000000 # Database -DB_NAME=project_db -DB_USER=postgres -DB_PASSWORD=postgres -DB_HOST=postgresql -DB_PORT=5432 +POSTGRES_DB=project_db +POSTGRES_USER=postgres +POSTGRES_PASSWORD=postgres # Redis REDIS_URI="redis://:@redis:6379" diff --git a/make-a-backup.sh b/make-a-backup.sh deleted file mode 100644 index f944155..0000000 --- a/make-a-backup.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env bash -set -e - -cd /home/django/project -docker exec -it django_1 python3 manage.py dumpdata --all --indent 4 --natural-primary --natural-foreign > /home/django/backups/dumpdata_$(date +"%Y-%m-%d").json -find /home/django/backups/* -mtime +30 -delete diff --git a/pre-commit-config.yaml b/pre-commit-config.yaml new file mode 100644 index 0000000..aa324a3 --- /dev/null +++ b/pre-commit-config.yaml @@ -0,0 +1,10 @@ +repos: +- repo: https://github.com/astral-sh/ruff-pre-commit + # Ruff version. + rev: v0.1.4 + hooks: + # Run the linter. + - id: ruff + args: [ --fix ] + # Run the formatter. + - id: ruff-format \ No newline at end of file diff --git a/ruff.toml b/ruff.toml new file mode 100644 index 0000000..b603ca9 --- /dev/null +++ b/ruff.toml @@ -0,0 +1,32 @@ +# Support Python 3.10+. +target-version = "py310" +# Set the maximum line length to 79. +line-length = 79 +exclude = [".venv", "venv", "coreplan/infra/http/django/asgi.py"] + +[lint] +# Add the `line-too-long` rule to the enforced rule set. By default, Ruff omits rules that +# overlap with the use of a formatter, like Black, but we can override this behavior by +# explicitly adding the rule. +#extend-select = ["E501"] +# FastAPI problem: B008 Do not perform function call `Depends` in argument defaults +ignore = ["F401", "E402", "E101", "E501", "B008"] +select = [ + # pycodestyle + "E", + # Pyflakes + "F", + # pyupgrade + "UP", + # flake8-bugbear + "B", + # flake8-simplify + "SIM", + # isort + "I", +] + +[format] +quote-style = "single" +indent-style = "tab" +