Add frontend service to Docker setup and configure networking

Introduced a new `frontend` service in `docker-compose.yml`, complete with build, healthchecks, and networking. Added a multi-stage Dockerfile for the frontend, a `.dockerignore` file, and a startup script to wait for the backend. Updated Next.js configuration for Docker compatibility and added API type definitions.
This commit is contained in:
2025-02-27 12:59:39 +01:00
parent 3f1e1320f2
commit 03f4792232
7 changed files with 105 additions and 17 deletions

View File

@@ -14,6 +14,8 @@ services:
interval: 5s
timeout: 5s
retries: 5
networks:
- app-network
backend:
build:
@@ -32,20 +34,33 @@ services:
depends_on:
db:
condition: service_healthy
networks:
- app-network
frontend:
build:
context: ./frontend
dockerfile: Dockerfile
args:
- NEXT_PUBLIC_API_URL=http://backend:8000
ports:
- "3000:3000"
environment:
- NODE_ENV=production
- NEXT_PUBLIC_API_URL=http://backend:8000
depends_on:
- backend
healthcheck:
test: ["CMD", "wget", "--spider", "http://localhost:3000"]
interval: 10s
timeout: 5s
retries: 3
networks:
- app-network
# frontend:
# build:
# context: .
# dockerfile: frontend/Dockerfile
# volumes:
# - ./frontend:/app
# - /app/node_modules
# ports:
# - "3000:3000"
# environment:
# - NEXT_PUBLIC_API_URL=http://backend:8000
# depends_on:
# - backend
volumes:
postgres_data:
postgres_data:
networks:
app-network:
driver: bridge