Add production Docker setup and update backend/frontend configs
Introduces .dockerignore, production Dockerfile and nginx config for frontend, and refactors docker-compose.yml for multi-service deployment. Updates backend and frontend code to support public API tagging, improves refund handling, adds test email endpoint, and migrates Orval config to TypeScript. Removes unused frontend Dockerfile and updates dependencies for React Query and Orval.
This commit is contained in:
@@ -1,44 +1,118 @@
|
||||
version: "3.9"
|
||||
services:
|
||||
backend:
|
||||
container_name: backend-vontor-cz
|
||||
build:
|
||||
context: ./backend
|
||||
dockerfile: dockerfile
|
||||
restart: always
|
||||
env_file:
|
||||
- ./backend/.env
|
||||
build: ./backend
|
||||
networks:
|
||||
- app_network
|
||||
depends_on:
|
||||
- db
|
||||
- redis
|
||||
volumes:
|
||||
- static-data:/app/collectedstaticfiles
|
||||
- media-data:/app/media
|
||||
command: sh -c "
|
||||
python manage.py migrate --verbosity 3 --noinput &&
|
||||
python manage.py check &&
|
||||
python manage.py collectstatic --clear --noinput --verbosity 3 &&
|
||||
python manage.py seed_app_config &&
|
||||
gunicorn -k uvicorn.workers.UvicornWorker vontor_cz.asgi:application --bind 0.0.0.0:8000"
|
||||
ports:
|
||||
- "8000:8000"
|
||||
volumes:
|
||||
- ./backend:/app
|
||||
depends_on:
|
||||
- redis
|
||||
command: daphne -b 0.0.0.0 -p 8000 vontor_cz.asgi:application
|
||||
|
||||
frontend:
|
||||
env_file:
|
||||
- ./frontend/.env
|
||||
build: ./frontend
|
||||
ports:
|
||||
- "5173:5173"
|
||||
volumes:
|
||||
- ./frontend:/app
|
||||
command: npm run dev
|
||||
|
||||
redis:
|
||||
image: redis:alpine
|
||||
ports:
|
||||
- "6379:6379"
|
||||
|
||||
|
||||
db:
|
||||
image: postgres:15-alpine
|
||||
container_name: postgres-vontor-cz
|
||||
restart: always
|
||||
env_file:
|
||||
- ./backend/.env
|
||||
image: postgres:16
|
||||
environment:
|
||||
POSTGRES_DB: mydb
|
||||
POSTGRES_USER: myuser
|
||||
POSTGRES_PASSWORD: mypassword
|
||||
volumes:
|
||||
- db-data:/var/lib/postgresql/data
|
||||
ports:
|
||||
- "5432:5432"
|
||||
networks:
|
||||
- app_network
|
||||
|
||||
|
||||
redis: #extremly fast db, stores data in RAM memory
|
||||
container_name: redis-vontor-cz
|
||||
image: redis:alpine
|
||||
restart: always
|
||||
env_file:
|
||||
- ./backend/.env
|
||||
volumes:
|
||||
- postgres_data:/var/lib/postgresql/data
|
||||
- redis-data:/data
|
||||
expose:
|
||||
- "6379"
|
||||
networks:
|
||||
- app_network
|
||||
|
||||
celery: #task queue for handling asynchronous/hard tasks
|
||||
container_name: celery-vontor-cz
|
||||
build:
|
||||
context: ./backend
|
||||
dockerfile: dockerfile
|
||||
command: sh -c "python manage.py migrate --noinput && celery -A vontor_cz worker --loglevel=info"
|
||||
restart: always
|
||||
env_file:
|
||||
- ./backend/.env
|
||||
depends_on:
|
||||
- redis
|
||||
- db
|
||||
- backend
|
||||
networks:
|
||||
- app_network
|
||||
|
||||
celery-beat: #periodic tasks scheduler
|
||||
container_name: celery-beat-vontor-cz
|
||||
build:
|
||||
context: ./backend
|
||||
dockerfile: dockerfile
|
||||
command: sh -c "python manage.py migrate --noinput && celery -A vontor_cz beat --loglevel=info"
|
||||
restart: always
|
||||
env_file:
|
||||
- ./backend/.env
|
||||
depends_on:
|
||||
- redis
|
||||
- db
|
||||
- backend
|
||||
networks:
|
||||
- app_network
|
||||
|
||||
#end of backend services -----------------------
|
||||
|
||||
nginx: #web server, reverse proxy, serves static files
|
||||
container_name: nginx-vontor-cz
|
||||
build:
|
||||
context: ./frontend
|
||||
dockerfile: Dockerfile.prod
|
||||
env_file:
|
||||
- ./frontend/.env
|
||||
ports:
|
||||
- 80:80
|
||||
# - 9000:80
|
||||
depends_on:
|
||||
- backend
|
||||
networks:
|
||||
- app_network
|
||||
volumes:
|
||||
- static-data:/app/collectedstaticfiles # static (Django)
|
||||
- media-data:/app/media # media (Django)
|
||||
- ./frontend/nginx/nginx.conf:/etc/nginx/nginx.conf:ro
|
||||
|
||||
|
||||
|
||||
networks:
|
||||
app_network:
|
||||
driver: bridge
|
||||
|
||||
volumes:
|
||||
postgres_data:
|
||||
redis-data:
|
||||
db-data:
|
||||
static-data:
|
||||
media-data:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user