Adapt docker-compose and nginx.conf for deployment on infra

This commit is contained in:
Gérald Colangelo
2026-04-02 11:41:09 +02:00
parent fde92f92db
commit 405ec8a300
3 changed files with 27 additions and 9 deletions

1
.env
View File

@@ -1,6 +1,7 @@
SECRET_KEY=tYmcw4icw9qlVU2wToq3Szpli6TLhKqsHFCh616oY3ZnbmUbKh1ehjZzcZZwtHKqcgE SECRET_KEY=tYmcw4icw9qlVU2wToq3Szpli6TLhKqsHFCh616oY3ZnbmUbKh1ehjZzcZZwtHKqcgE
DEBUG=True DEBUG=True
ALLOWED_HOSTS=localhost,127.0.0.1,web ALLOWED_HOSTS=localhost,127.0.0.1,web
NETWORK=shooter-hub_default
DATABASE_URL=postgresql://shooter:shooter_secret@db:5432/shooter_hub DATABASE_URL=postgresql://shooter:shooter_secret@db:5432/shooter_hub

View File

@@ -12,8 +12,12 @@ services:
interval: 5s interval: 5s
timeout: 5s timeout: 5s
retries: 5 retries: 5
networks:
local_net:
aliases:
- ${COMPOSE_PROJECT_NAME}-db
web: app:
build: . build: .
command: > command: >
sh -c "python manage.py migrate --noinput && sh -c "python manage.py migrate --noinput &&
@@ -23,23 +27,36 @@ services:
python manage.py runserver 0.0.0.0:8000" python manage.py runserver 0.0.0.0:8000"
volumes: volumes:
- .:/app - .:/app
ports: #ports:
- "8000:8000" #- "8000:8000"
depends_on: depends_on:
db: db:
condition: service_healthy condition: service_healthy
env_file: env_file:
- .env - .env
networks:
local_net:
aliases:
- ${COMPOSE_PROJECT_NAME}-app
frontend: web:
image: nginx:alpine image: nginx:alpine
volumes: volumes:
- ./frontend:/usr/share/nginx/html:ro - ./frontend:/usr/share/nginx/html:ro
- ./frontend/nginx.conf:/etc/nginx/conf.d/default.conf:ro - ./frontend/nginx.conf:/etc/nginx/conf.d/default.conf:ro
ports: # ports:
- "5173:80" #- "5173:80"
depends_on: depends_on:
- web - app
networks:
local_net:
aliases:
- ${COMPOSE_PROJECT_NAME}-web
volumes: volumes:
postgres_data: postgres_data:
networks:
local_net:
name: ${NETWORK}
external: true

View File

@@ -5,7 +5,7 @@ server {
# Proxy API calls to Django # Proxy API calls to Django
location /api/ { location /api/ {
proxy_pass http://web:8000; proxy_pass http://app:8000;
proxy_set_header Host web; proxy_set_header Host web;
proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
@@ -14,7 +14,7 @@ server {
# Proxy media files to Django # Proxy media files to Django
location /media/ { location /media/ {
proxy_pass http://web:8000; proxy_pass http://app:8000;
proxy_set_header Host web; proxy_set_header Host web;
} }