


# Docker Compose Setup

## ENV Vars

- DOMAIN
- PDF_LICENSE
- DB_PASS
- DB_USER
- CONTACT_EMAIL

## Docker Compose File
~~~
services:
    frontend:
        image: git.federspiel.tech/flfeders/fedeo/frontend:main
        restart: always
        environment:
            - NUXT_PUBLIC_API_BASE=https://${DOMAIN}/backend
            - NUXT_PUBLIC_PDF_LICENSE=${PDF_LICENSE}
        networks:
            - traefik
        labels:
            - "traefik.enable=true"
            - "traefik.docker.network=traefik"
            - "traefik.port=3000"
            # Middlewares
            - "traefik.http.middlewares.fedeo-frontend-redirect-web-secure.redirectscheme.scheme=https"
            # Web Entrypoint
            - "traefik.http.routers.fedeo-frontend.middlewares=fedeo-frontend-redirect-web-secure"
            - "traefik.http.routers.fedeo-frontend.rule=Host(`${DOMAIN}`) && PathPrefix(`/`)"
            - "traefik.http.routers.fedeo-frontend.entrypoints=web"
            # Web Secure Entrypoint
            - "traefik.http.routers.fedeo-frontend-secure.rule=Host(`${DOMAIN}`) && PathPrefix(`/`)"
            - "traefik.http.routers.fedeo-frontend-secure.entrypoints=web-secured" #
            - "traefik.http.routers.fedeo-frontend-secure.tls.certresolver=mytlschallenge"
    backend:
        image: git.federspiel.tech/flfeders/fedeo/backend:main
        restart: always
        environment:
            - INFISICAL_CLIENT_ID=
            - INFISICAL_CLIENT_SECRET=
            - NODE_ENV=production
        networks:
            - traefik
        labels:
            - "traefik.enable=true"
            - "traefik.docker.network=traefik"
            - "traefik.port=3100"
            # Middlewares
            - "traefik.http.middlewares.fedeo-backend-redirect-web-secure.redirectscheme.scheme=https"
            - "traefik.http.middlewares.fedeo-backend-strip.stripprefix.prefixes=/backend"
            # Web Entrypoint
            - "traefik.http.routers.fedeo-backend.middlewares=fedeo-backend-redirect-web-secure"
            - "traefik.http.routers.fedeo-backend.rule=Host(`${DOMAIN}`) && PathPrefix(`/backend`)"
            - "traefik.http.routers.fedeo-backend.entrypoints=web"
            # Web Secure Entrypoint
            - "traefik.http.routers.fedeo-backend-secure.rule=Host(`${DOMAIN}`) && PathPrefix(`/backend`)"
            - "traefik.http.routers.fedeo-backend-secure.entrypoints=web-secured" #
            - "traefik.http.routers.fedeo-backend-secure.tls.certresolver=mytlschallenge"
            - "traefik.http.routers.fedeo-backend-secure.middlewares=fedeo-backend-strip"
    #  db:
    #    image: postgres
    #    restart: always
    #    shm_size: 128mb
    #    environment:
    #      POSTGRES_PASSWORD: 
    #      POSTGRES_USER: 
    #      POSTGRES_DB: 
    #    volumes:
    #      - ./pg-data:/var/lib/postgresql/data
    #    ports:
    #      - "5432:5432"
    traefik:
        image: traefik:v2.11
        restart: unless-stopped
        container_name: traefik
        command:
            - "--api.insecure=false"
            - "--api.dashboard=false"
            - "--api.debug=false"
            - "--providers.docker=true"
            - "--providers.docker.exposedbydefault=false"
            - "--providers.docker.network=traefik"
            - "--entrypoints.web.address=:80"
            - "--entrypoints.web-secured.address=:443"
            - "--accesslog=true"
            - "--accesslog.filepath=/logs/access.log"
            - "--accesslog.bufferingsize=5000"
            - "--accesslog.fields.defaultMode=keep"
            - "--accesslog.fields.headers.defaultMode=keep"
            - "--certificatesresolvers.mytlschallenge.acme.tlschallenge=true" #
            - "--certificatesresolvers.mytlschallenge.acme.email=${CONTACT_EMAIL}"
            - "--certificatesresolvers.mytlschallenge.acme.storage=/letsencrypt/acme.json"
        ports:
            - 80:80
            - 443:443
        volumes:
            - "./traefik/letsencrypt:/letsencrypt" # <== Volume for certs (TLS)
            - "/var/run/docker.sock:/var/run/docker.sock:ro"
            - "./traefik/logs:/logs"
        networks:
            - traefik
networks:
    traefik:
        external: false
~~~