Advertisement
nuclearsmilz

docker compose - backend+traefik

Jul 4th, 2025 (edited)
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 2.60 KB | None | 0 0
  1. # Unified Docker Compose file for Hackalyst (Traefik + Backend)
  2.  
  3. services:
  4.   traefik:
  5.     image: traefik:latest
  6.     container_name: traefik
  7.     restart: unless-stopped
  8.     environment:
  9.      # Use staging Let's Encrypt server for development to avoid rate limits
  10.       - ACME_CA_SERVER=https://acme-staging-v02.api.letsencrypt.org/directory
  11.       # Hardcoded for local development
  12.       - TRAEFIK_DASHBOARD_CRED=user:pass (removed real value for pastebin)
  13.     ports:
  14.      - "80:80"
  15.       - "443:443"
  16.       - "8081:8080" # Dashboard port for development (changed to 8081 to avoid conflicts)
  17.     volumes:
  18.      - ./backend/infra/traefik/traefik.yml:/etc/traefik/traefik.yml:ro
  19.       - ./backend/infra/traefik/dynamic:/etc/traefik/dynamic:ro
  20.       - ./backend/infra/traefik/acme/acme.json:/acme/acme.json
  21.       - /var/run/docker.sock:/var/run/docker.sock:ro # For Docker provider to work
  22.     networks:
  23.      - proxy
  24.     command:
  25.      - "--providers.docker.exposedbydefault=false"
  26.       - "--api.insecure=true" # Allow insecure access to dashboard in development
  27.     labels:
  28.      - "traefik.enable=true"
  29.       - "traefik.http.routers.dashboard-local.rule=Host(`localhost`) && (PathPrefix(`/api`) || PathPrefix(`/dashboard`))"
  30.       - "traefik.http.routers.dashboard-local.service=api@internal"
  31.       - "traefik.http.routers.dashboard-local.entrypoints=dashboard"
  32.  
  33.   backend:
  34.     build:
  35.       context: ./backend
  36.       dockerfile: Dockerfile
  37.     image: hackalyst-backend
  38.     container_name: hackalyst-backend
  39.     restart: unless-stopped
  40.     environment:
  41.      - NODE_ENV=development
  42.       - MONGODB_URI=mongodb://localhost:27017/hackalyst
  43.       - CLERK_JWKS_PUBLIC_KEY=dummy_key
  44.       # Uncomment these for production with Infisical
  45.       # - INFISICAL_MACHINE_IDENTITY_ID=${INFISICAL_MACHINE_IDENTITY_ID}
  46.       # - INFISICAL_MACHINE_IDENTITY_CLIENT_SECRET=${INFISICAL_MACHINE_IDENTITY_CLIENT_SECRET}
  47.       # - INFISICAL_PROJECT_ID=${INFISICAL_PROJECT_ID}
  48.     volumes:
  49.      - ./backend:/root/app
  50.     networks:
  51.      - proxy
  52.     labels:
  53.      - "traefik.enable=true"
  54.       - "traefik.http.routers.backend.rule=Host(`backend.hackalyst.com`)"
  55.       - "traefik.http.routers.backend.entrypoints=websecure"
  56.       - "traefik.http.routers.backend.tls.certresolver=letsencrypt"
  57.       - "traefik.http.services.backend.loadbalancer.server.port=3000"
  58.       # For local non-TLS access
  59.       - "traefik.http.routers.backend-insecure.rule=Host(`backend.hackalyst.com`)"
  60.       - "traefik.http.routers.backend-insecure.entrypoints=web"
  61.  
  62. networks:
  63.   proxy:
  64.     name: proxy
  65.     external: true # Use an existing network
  66.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement