From 75c5adf3460b8eb215b5eb57ede3529fb84471a2 Mon Sep 17 00:00:00 2001 From: Gabriel Kaszewski Date: Tue, 9 Sep 2025 04:45:24 +0200 Subject: [PATCH] fix: reorganize Traefik labels and network configuration in Docker Compose --- compose.prod.yml | 62 ++++++++++++++---------------------------------- 1 file changed, 18 insertions(+), 44 deletions(-) diff --git a/compose.prod.yml b/compose.prod.yml index 41e2f7e..0cc9365 100644 --- a/compose.prod.yml +++ b/compose.prod.yml @@ -39,21 +39,7 @@ services: timeout: 5s retries: 5 networks: - - traefik - internal - labels: - - "traefik.enable=true" - - "traefik.docker.network=traefik" - # Create a router for the API - - "traefik.http.routers.thoughts-api.rule=Host(`thoughts.gabrielkaszewski.dev`) && PathPrefix(`/api`)" - - "traefik.http.routers.thoughts-api.entrypoints=web,websecure" - - "traefik.http.routers.thoughts-api.tls.certresolver=letsencrypt" - - "traefik.http.routers.thoughts-api.service=thoughts-api" - # Add a middleware to strip the /api prefix before sending to the backend - - "traefik.http.routers.thoughts-api.middlewares=strip-api-prefix" - - "traefik.http.middlewares.strip-api-prefix.stripprefix.prefixes=/api" - # Create a service for the API that points to the backend container's port - - "traefik.http.services.thoughts-api.loadbalancer.server.port=8000" frontend: container_name: thoughts-frontend @@ -71,40 +57,28 @@ services: - PORT=3000 - HOSTNAME=0.0.0.0 networks: - - traefik - internal + + proxy: + container_name: thoughts-proxy + image: custom-proxy:latest + restart: unless-stopped + depends_on: + frontend: + condition: service_healthy + backend: + condition: service_healthy + networks: + - internal + - traefik labels: - "traefik.enable=true" - "traefik.docker.network=traefik" - # Create a router for the main web traffic - - "traefik.http.routers.thoughts-web.rule=Host(`thoughts.gabrielkaszewski.dev`)" - - "traefik.http.routers.thoughts-web.entrypoints=web,websecure" - - "traefik.http.routers.thoughts-web.tls.certresolver=letsencrypt" - - "traefik.http.routers.thoughts-web.service=thoughts-web" - # Give this router a lower priority so the more specific /api route is matched first - - "traefik.http.routers.thoughts-web.priority=1" - # Create a service for the web that points to the frontend container's port - - "traefik.http.services.thoughts-web.loadbalancer.server.port=3000" - - # proxy: - # container_name: thoughts-proxy - # image: custom-proxy:latest - # restart: unless-stopped - # depends_on: - # frontend: - # condition: service_healthy - # backend: - # condition: service_healthy - # networks: - # - internal - # - traefik - # labels: - # - "traefik.enable=true" - # - "traefik.http.routers.thoughts.rule=Host(`thoughts.gabrielkaszewski.dev`)" - # - "traefik.http.routers.thoughts.entrypoints=web,websecure" - # - "traefik.http.routers.thoughts.tls.certresolver=letsencrypt" - # - "traefik.http.routers.thoughts.service=thoughts" - # - "traefik.http.services.thoughts.loadbalancer.server.port=80" + - "traefik.http.routers.thoughts.rule=Host(`thoughts.gabrielkaszewski.dev`)" + - "traefik.http.routers.thoughts.entrypoints=web,websecure" + - "traefik.http.routers.thoughts.tls.certresolver=letsencrypt" + - "traefik.http.routers.thoughts.service=thoughts" + - "traefik.http.services.thoughts.loadbalancer.server.port=80" volumes: postgres_data: