services: db: image: postgres:latest container_name: postgres restart: always volumes: - postgres_data:/var/lib/postgresql/data ports: - "5432:5432" healthcheck: test: ["CMD-SHELL", "pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}"] interval: 10s timeout: 5s retries: 5 networks: - app-network environment: POSTGRES_DB: ${POSTGRES_DB} POSTGRES_USER: ${POSTGRES_USER} POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} backend: build: context: . dockerfile: Dockerfile image: backend container_name: backend restart: always command: /bin/sh -c "sleep 5 && venv/bin/python manage.py makemigrations --noinput && venv/bin/python manage.py migrate --noinput && venv/bin/python manage.py collectstatic --noinput && venv/bin/daphne -b 0.0.0.0 -p 80 pong.asgi:application" volumes: - pong:/transcendence/pong ports: - "80:80" depends_on: - db networks: - app-network environment: DB_HOST: db DB_PORT: 5432 DB_NAME: ${POSTGRES_DB} DB_USER: ${POSTGRES_USER} DB_PASSWORD: ${POSTGRES_PASSWORD} healthcheck: test: ["CMD-SHELL", "curl -f http://localhost:80 || exit 1"] interval: 10s timeout: 5s retries: 5 volumes: postgres_data: driver: local driver_opts: type: none device: ${POSTGRES_DATA_PATH} o: bind pong: driver: local driver_opts: type: none device: ${PROJECT_PATH} o: bind networks: app-network: driver: bridge