version: "3.9"

services:
  api:
    image: xemle/home-gallery-api-server
    container_name: home-gallery-api-server
    restart: unless-stopped
    security_opt:
      - no-new-privileges:true
    networks:
      - proxy
    environment:
      # TensorflowJS backends
      # - cpu: slowest and best support
      # - wasm: good perfromance for arm64 and amd64 platforms
      # - node: best performance on amd64 platform
      #- BACKEND=cpu
      # - BACKEND=wasm
      - BACKEND=node
  gallery:
    # custom build via
    #build: .
    image: xemle/home-gallery
    container_name: home-gallery
    restart: unless-stopped
    security_opt:
      - no-new-privileges:true
    networks:
      - proxy
    environment:
      - GALLERY_API_SERVER=http://api:3000
      #- GALLERY_API_SERVER_CONCURRENT=1 # On low powered devices
      #- GALLERY_API_SERVER_TIMEOUT=60 # On low powered devices
      - GALLERY_OPEN_BROWSER=false
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - ${PWD}/home-gallery/data:/data
      # Mount your media directories below /data
      # - ${HOME}/Pictures:/data/Pictures
      - /tank/home-gallery/:/data/Pictures
    # ports:
    #   - "3000:3000"
    entrypoint: ["node", "/app/gallery.js"]
    command: ["run", "server"]

    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.home-gallery.entrypoints=http"
      - "traefik.http.routers.home-gallery.rule=Host(`home-gallery.${URL}`)"
      - "traefik.http.middlewares.home-gallery-https-redirect.redirectscheme.scheme=https"
      - "traefik.http.routers.home-gallery.middlewares=home-gallery-https-redirect"
      - "traefik.http.routers.home-gallery-secure.entrypoints=https"
      - "traefik.http.routers.home-gallery-secure.rule=Host(`home-gallery.${URL}`)"
      - "traefik.http.routers.home-gallery-secure.tls=true"
      - "traefik.http.routers.home-gallery-secure.service=home-gallery"
      - "traefik.http.services.home-gallery.loadbalancer.server.port=3000"
      - "traefik.docker.network=proxy"

networks:
  proxy:
    external: true
