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
DEBUG=True
ALLOWED_HOSTS=localhost,127.0.0.1,web
NETWORK=shooter-hub_default
DATABASE_URL=postgresql://shooter:shooter_secret@db:5432/shooter_hub

View File

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

View File

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