Refactor Docker setup for environment flexibility and dev support
Moved environment variables to .env.template for better management and updated docker-compose files to use them. Added separate docker-compose.dev.yml for development, a Makefile for streamlined commands, and split backend Dockerfile into development and production stages. Updated .gitignore to include new changes.
This commit is contained in:
74
docker-compose.dev.yml
Normal file
74
docker-compose.dev.yml
Normal file
@@ -0,0 +1,74 @@
|
||||
services:
|
||||
db:
|
||||
image: postgres:17-alpine
|
||||
volumes:
|
||||
- postgres_data_dev:/var/lib/postgresql/data/
|
||||
environment:
|
||||
- POSTGRES_USER=${POSTGRES_USER}
|
||||
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
|
||||
- POSTGRES_DB=${POSTGRES_DB}
|
||||
ports:
|
||||
- "5432:5432"
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER}"]
|
||||
interval: 5s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
networks:
|
||||
- app-network
|
||||
|
||||
backend:
|
||||
build:
|
||||
context: ./backend
|
||||
dockerfile: Dockerfile
|
||||
target: development
|
||||
volumes:
|
||||
- ./backend:/app
|
||||
- ./uploads:/app/uploads
|
||||
- backend_dev_modules:/app/.venv
|
||||
ports:
|
||||
- "8000:8000"
|
||||
environment:
|
||||
- DATABASE_URL=${DATABASE_URL}
|
||||
- SECRET_KEY=${SECRET_KEY}
|
||||
- ENVIRONMENT=development
|
||||
- DEBUG=true
|
||||
- BACKEND_CORS_ORIGINS=${BACKEND_CORS_ORIGINS}
|
||||
depends_on:
|
||||
db:
|
||||
condition: service_healthy
|
||||
networks:
|
||||
- app-network
|
||||
command: ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"]
|
||||
|
||||
frontend:
|
||||
build:
|
||||
context: ./frontend
|
||||
dockerfile: Dockerfile
|
||||
target: deps
|
||||
args:
|
||||
- NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL}
|
||||
volumes:
|
||||
- ./frontend:/app
|
||||
- frontend_dev_modules:/app/node_modules
|
||||
- frontend_dev_next:/app/.next
|
||||
ports:
|
||||
- "3000:3000"
|
||||
environment:
|
||||
- NODE_ENV=development
|
||||
- NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL}
|
||||
depends_on:
|
||||
- backend
|
||||
command: npm run dev
|
||||
networks:
|
||||
- app-network
|
||||
|
||||
volumes:
|
||||
postgres_data_dev:
|
||||
backend_dev_modules:
|
||||
frontend_dev_modules:
|
||||
frontend_dev_next:
|
||||
|
||||
networks:
|
||||
app-network:
|
||||
driver: bridge
|
||||
Reference in New Issue
Block a user