This commit is contained in:
Andros Fenollosa 2024-08-31 14:50:48 +02:00
parent 58ea6b12f6
commit 6db5005de2
9 changed files with 104 additions and 149 deletions

View File

@ -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
}

View File

@ -1,11 +0,0 @@
https://project.com
root * /usr/src/app/
@notStatic {
not path /static/* /media/*
}
reverse_proxy @notStatic django:8000
file_server

11
asgi.py
View File

@ -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({})

58
compose.yaml Normal file
View File

@ -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

View File

@ -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:

View File

@ -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"

View File

@ -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

10
pre-commit-config.yaml Normal file
View File

@ -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

32
ruff.toml Normal file
View File

@ -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"