---

version: "3"

services:
  todo-webserver:
    container_name: todo-webserver
    restart: unless-stopped
    build:
      context: .
      dockerfile: production.webserver.Dockerfile
      args:
        CUSTOM_UID: 1000
        CUSTOM_GID: 1000
    networks:
      - proxy
      - todo
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.todo.entrypoints=https"
      - "traefik.http.routers.todo.rule=Host(`todo.example.com`)"
      - "traefik.http.routers.todo-secure.middlewares=default@file"
      - "traefik.http.routers.todo.tls=true"
      - "traefik.http.services.todo.loadbalancer.server.port=8000"
      - 'traefik.docker.network=proxy'
  todo-frontend:
    container_name: todo-frontend
    restart: unless-stopped
    depends_on:
      - todo-webserver
    build:
      context: .
      dockerfile: production.frontend.Dockerfile
      args:
        CUSTOM_UID: 1000
        CUSTOM_GID: 1000
    networks:
      - todo
    expose:
      - "3000"
  todo-backend:
    container_name: todo-backend
    restart: unless-stopped
    depends_on:
      - todo-webserver
      - todo-db
    build:
      context: .
      dockerfile: ./production.backend.Dockerfile
      args:
        CUSTOM_UID: 1000
        CUSTOM_GID: 1000
    networks:
      - todo
    expose:
      - "3000"
    environment:
      APP_NAME: "TodoApp"
      ADMIN_EMAIL: "admin@example.com"
      DEBUG_MODE: "true"
      POSTGRES_HOST: "todo-db"
      POSTGRES_PORT: "5432"
      POSTGRES_DB: "todo"
      POSTGRES_USER: "todo"
      POSTGRES_PASSWORD: "todo"
      JWT_SECRET: "todo"
      JWT_EXPIRATION_TIME: "172800"
  todo-db:
    image: postgres:alpine
    container_name: todo-db
    restart: unless-stopped
    networks:
      - todo
    expose:
      - "5432"
    volumes:
      - /srv/todo/data:/var/lib/postgresql/data
    environment:
      TZ: Europe/Berlin
      POSTGRES_DB: "todo"
      POSTGRES_USER: "todo"
      POSTGRES_PASSWORD: "todo"

networks:
  proxy:
    external: true
  todo:
    external: false

...
