forked from val-lop20/Pagina-de-Asistencia-MAC
81 lines
2.0 KiB
YAML
81 lines
2.0 KiB
YAML
services:
|
|
# PostgreSQL Database
|
|
db:
|
|
image: postgres:15-alpine
|
|
environment:
|
|
- POSTGRES_DB=mac_attendance
|
|
- POSTGRES_USER=mac_user
|
|
- POSTGRES_PASSWORD=mac_password_2024_secure
|
|
volumes:
|
|
- postgres_data:/var/lib/postgresql/data
|
|
networks:
|
|
- app-network
|
|
ports:
|
|
- "5432:5432" # Expuesto para acceso desde host (comentar en producción si no es necesario)
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U mac_user -d mac_attendance"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
|
|
# Backend Django
|
|
backend:
|
|
build:
|
|
context: .
|
|
dockerfile: docker/Dockerfile.backend
|
|
command: >
|
|
sh -c "python manage.py migrate &&
|
|
python manage.py collectstatic --noinput &&
|
|
gunicorn --bind 0.0.0.0:8000 --workers 3 --timeout 120 mac_attendance.wsgi:application"
|
|
volumes:
|
|
- ./backend:/app
|
|
- static_volume:/app/staticfiles
|
|
- media_volume:/app/media
|
|
environment:
|
|
- DEBUG=True
|
|
- SECRET_KEY=django-insecure-dev-key-change-in-production-12345
|
|
- ALLOWED_HOSTS=localhost,127.0.0.1,nginx,backend
|
|
- RATELIMIT_ENABLE=False
|
|
- SECURE_SSL_REDIRECT=False
|
|
- SESSION_COOKIE_SECURE=False
|
|
- CSRF_COOKIE_SECURE=False
|
|
- CORS_ALLOWED_ORIGINS=http://localhost,http://127.0.0.1,http://localhost:80
|
|
- DB_ENGINE=postgresql
|
|
- DB_NAME=mac_attendance
|
|
- DB_USER=mac_user
|
|
- DB_PASSWORD=mac_password_2024_secure
|
|
- DB_HOST=db
|
|
- DB_PORT=5432
|
|
networks:
|
|
- app-network
|
|
depends_on:
|
|
db:
|
|
condition: service_healthy
|
|
expose:
|
|
- "8000"
|
|
|
|
# Frontend React + Nginx
|
|
nginx:
|
|
build:
|
|
context: .
|
|
dockerfile: docker/Dockerfile.frontend
|
|
ports:
|
|
- "80:80"
|
|
volumes:
|
|
- ./docker/nginx.conf:/etc/nginx/conf.d/default.conf
|
|
- static_volume:/app/staticfiles
|
|
- media_volume:/app/media
|
|
depends_on:
|
|
- backend
|
|
networks:
|
|
- app-network
|
|
|
|
networks:
|
|
app-network:
|
|
driver: bridge
|
|
|
|
volumes:
|
|
static_volume:
|
|
media_volume:
|
|
postgres_data:
|