Files
demystifying-docker/examples/fullstack/compose.yml
2025-06-11 19:03:54 -04:00

53 lines
1.6 KiB
YAML

services:
frontend:
image: frontend:latest
build:
context: ./frontend
target: develop
volumes:
- frontend_node_modules:/app/node_modules
- ./frontend/src:/app/src
labels:
- "traefik.http.routers.app.rule=Host(`app.docker.localhost`)"
reverse-proxy:
image: traefik:latest
command: --api.insecure=true --providers.docker
ports:
- 8888:80
- 8080:8080
volumes:
# So that Traefik can listen to the Docker events
- /var/run/docker.sock:/var/run/docker.sock
backend:
image: backend:latest
build:
context: ./backend
volumes:
- backend_node_modules:/backend/node_modules
- ./backend/:/backend
labels:
- "traefik.http.middlewares.strip-api-prefix.stripprefix.prefixes=/api"
- "traefik.http.routers.backend.rule=Host(`app.docker.localhost`) && PathPrefix(`/api`)"
- "traefik.http.routers.backend.middlewares=strip-api-prefix@docker"
env_file:
- ./backend/.env
depends_on:
db:
condition: service_healthy
db:
image: postgres:latest
environment:
- POSTGRES_PASSWORD=postgres
healthcheck:
test: pg_isready --d postgres --user postgres
interval: 5s
# By default docker compose will create a bridge network using the folder name where the docker-compose.yml
# resides and attach all containers in the compose file to that network. This is important because it allows
# for easier container to container networking.
# Isolate our node_modules from our host system. Docker will handle creating these volumes
volumes:
frontend_node_modules:
backend_node_modules: