|
| 1 | +version: '3.8' |
| 2 | + |
| 3 | +services: |
| 4 | + # Traefik - reverse proxy with dashboard |
| 5 | + traefik: |
| 6 | + image: traefik:v2.10 |
| 7 | + container_name: traefik |
| 8 | + command: |
| 9 | + - "--api.insecure=false" |
| 10 | + - "--providers.docker=true" |
| 11 | + - "--providers.docker.exposedbydefault=false" |
| 12 | + - "--entrypoints.web.address=:80" |
| 13 | + - "--entrypoints.websecure.address=:443" |
| 14 | + - "--entrypoints.dashboard.address=:8080" |
| 15 | + # Enable automatic HTTPS with Let's Encrypt |
| 16 | + - "--certificatesresolvers.leresolver.acme.httpchallenge=true" |
| 17 | + - "--certificatesresolvers.leresolver.acme.httpchallenge.entrypoint=web" |
| 18 | + - "--certificatesresolvers.leresolver.acme.email=admin@devopsterminal.com" |
| 19 | + - "--certificatesresolvers.leresolver.acme.storage=/letsencrypt/acme.json" |
| 20 | + # Enable dashboard |
| 21 | + - "--api.dashboard=true" |
| 22 | + # Use podman network |
| 23 | + - "--providers.docker.network=prod_network" |
| 24 | + ports: |
| 25 | + - "80:80" |
| 26 | + - "443:443" |
| 27 | + - "8080:8080" # Dashboard - should be restricted in production |
| 28 | + volumes: |
| 29 | + - "/var/run/docker.sock:/var/run/docker.sock:ro" |
| 30 | + - "./letsencrypt:/letsencrypt" |
| 31 | + - "./traefik/traefik.log:/traefik.log" |
| 32 | + - "./traefik/access.log:/access.log" |
| 33 | + environment: |
| 34 | + - TZ=Europe/Warsaw |
| 35 | + restart: unless-stopped |
| 36 | + networks: |
| 37 | + - prod_network |
| 38 | + labels: |
| 39 | + - "traefik.enable=true" |
| 40 | + # Dashboard protection |
| 41 | + - "traefik.http.routers.dashboard.rule=Host(`traefik.devopsterminal.com`)" |
| 42 | + - "traefik.http.routers.dashboard.service=api@internal" |
| 43 | + - "traefik.http.routers.dashboard.entrypoints=websecure" |
| 44 | + - "traefik.http.routers.dashboard.tls.certresolver=leresolver" |
| 45 | + - "traefik.http.routers.dashboard.middlewares=auth" |
| 46 | + # Basic auth for dashboard (user:admin, password:changeme) |
| 47 | + - "traefik.http.middlewares.auth.basicauth.users=admin:$$2y$$05$$5HXxP9X8wJqTgYz5jK5u8uJq5VZ5QkXJ5zQ9X8wJqTgYz5jK5u8uJ" |
| 48 | + |
| 49 | + # Project 1 Service |
| 50 | + projekt1: |
| 51 | + build: ./projekt1 |
| 52 | + container_name: projekt1 |
| 53 | + restart: unless-stopped |
| 54 | + networks: |
| 55 | + - prod_network |
| 56 | + labels: |
| 57 | + - "traefik.enable=true" |
| 58 | + # Main domain |
| 59 | + - "traefik.http.routers.projekt1.rule=Host(`projekt1.devopsterminal.com`)" |
| 60 | + - "traefik.http.routers.projekt1.entrypoints=websecure" |
| 61 | + - "traefik.http.routers.projekt1.tls.certresolver=leresolver" |
| 62 | + - "traefik.http.services.projekt1.loadbalancer.server.port=5000" |
| 63 | + # Redirect HTTP to HTTPS |
| 64 | + - "traefik.http.routers.projekt1-http.rule=Host(`projekt1.devopsterminal.com`)" |
| 65 | + - "traefik.http.routers.projekt1-http.entrypoints=web" |
| 66 | + - "traefik.http.routers.projekt1-http.middlewares=redirect-to-https@docker" |
| 67 | + environment: |
| 68 | + - FLASK_ENV=production |
| 69 | + |
| 70 | + # Project 2 Service |
| 71 | + projekt2: |
| 72 | + build: ./projekt2 |
| 73 | + container_name: projekt2 |
| 74 | + restart: unless-stopped |
| 75 | + networks: |
| 76 | + - prod_network |
| 77 | + labels: |
| 78 | + - "traefik.enable=true" |
| 79 | + # Main domain |
| 80 | + - "traefik.http.routers.projekt2.rule=Host(`projekt2.devopsterminal.com`)" |
| 81 | + - "traefik.http.routers.projekt2.entrypoints=websecure" |
| 82 | + - "traefik.http.routers.projekt2.tls.certresolver=leresolver" |
| 83 | + - "traefik.http.services.projekt2.loadbalancer.server.port=5000" |
| 84 | + # Redirect HTTP to HTTPS |
| 85 | + - "traefik.http.routers.projekt2-http.rule=Host(`projekt2.devopsterminal.com`)" |
| 86 | + - "traefik.http.routers.projekt2-http.entrypoints=web" |
| 87 | + - "traefik.http.routers.projekt2-http.middlewares=redirect-to-https@docker" |
| 88 | + environment: |
| 89 | + - FLASK_ENV=production |
| 90 | + |
| 91 | + # Global redirect middleware |
| 92 | + traefik-http-redirect: |
| 93 | + image: traefik:v2.10 |
| 94 | + command: --providers.directory.watch=true --providers.file.directory=/etc/traefik --providers.file.watch=true |
| 95 | + volumes: |
| 96 | + - ./traefik/redirect.toml:/etc/traefik/redirect.toml |
| 97 | + networks: |
| 98 | + - prod_network |
| 99 | + labels: |
| 100 | + - "traefik.enable=true" |
| 101 | + - "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https" |
| 102 | + - "traefik.http.middlewares.redirect-to-https.redirectscheme.permanent=true" |
| 103 | + |
| 104 | +networks: |
| 105 | + prod_network: |
| 106 | + name: prod_network |
| 107 | + external: false |
0 commit comments