Docker Compose

Docker compose simplifies the configuration of containers and connected services. Following example starts the HomeGallery with a local API server.

version: "3.9"
services:
  api:
    # custom build via
    #build: packages/api-server
    image: xemle/home-gallery-api-server
    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
    environment:
      - GALLERY_API_SERVER=http://api:3000
      - GALLERY_API_SERVER_CONCURRENT=1 # for SoC devices like Rasperry Pi. Use 5 otherwise
      - GALLERY_API_SERVER_TIMEOUT=60 # for SoC devices like Rasperry Pi. Use 30 otherwise
      #- GALLERY_USE_NATIVE=ffprobe,ffmpeg,vipsthumbnail # On issues with sharp resizer
      - GALLERY_OPEN_BROWSER=false
      # Use polling for safety of possible network mounts. Try 0 to use inotify via fs.watch
      - GALLERY_WATCH_POLL_INTERVAL=300
    volumes:
      - ./data:/data
      # Mount your media directories below /data
      - ${HOME}/Pictures:/data/Pictures
    ports:
      - "3000:3000"
    user: "${CURRENT_USER}"
    entrypoint: ['node', '/app/gallery.js']
    command: ['run', 'server']
Note

By default the wasm backend for the API server is used for best support on most platforms (SoS, NAS, cloud and desktop). Use node backend for best performance on amd64 CPUs like desktops. Please validate that the backend node works for you.

Quickstart

mkdir -p data/config
echo "CURRENT_USER=$(id -u):$(id -g)" >> .env
docker compose run gallery run init --source /data/Pictures
docker compose up -d
Note

The docker container is configured to poll image sources each 5 minutes for compatibility reasons of slow or large media volumes. Check if inotify through disabled polling by GALLERY_WATCH_POLL_INTERVAL=0 is working for you.

Run the CLI

The CLI with all commands is started via docker compose

docker compose run gallery -h

This CLI is attached to the pseudo-tty. To run it as background job like in cron jobs, pleas use -T argument

docker compose run -T gallery -h

To upgrade the gallery software, please pull the latest container and restart your services.

Please run the import command after an application upgrade to rebuild the database. This step will add new features and fix missing database entries. If all your media is already imported the import can be done while the server is running

docker compose pull
docker compose run gallery run import
# For cron update task use -T to disable pseudo-tty allocation
#docker compose run -T gallery run import
docker compose up -d