services:
  web:
    build:
      context: .
      secrets:
        - FLUXON_KEY_FINGERPRINT
        - FLUXON_LICENSE_KEY
    image: fullyforged/music_library:latest
    container_name: web
    init: true
    ports:
      - 8080
    environment:
      - API_TOKEN
      - BACKGROUND_DATABASE_PATH
      - CLOAK_ENCRIPTION_KEY
      - DATABASE_PATH
      - DISCOGS_PERSONAL_ACCESS_TOKEN
      - LAST_FM_API_KEY
      - LAST_FM_SHARED_SECRET
      - LAST_FM_USER
      - LOGIN_PASSWORD
      - MIX_ENV
      - OPENAI_KEY
      - POOL_SIZE
      - PORT
      - SECRET_KEY_BASE
      - TELEMETRY_DATABASE_PATH
      - TIMEZONE
    volumes:
      - /data/coolify/applications/music-library:/mnt/music_library
    healthcheck:
      test: ["CMD-SHELL", "bin/music_library pid"]
      interval: 10s
      timeout: 20s
      retries: 10
  backup:
    image: litestream/litestream:0.5.11-scratch
    container_name: backup
    user: "0"
    configs:
      - source: litestream
        target: /opt/litestream/litestream.yaml
    volumes:
      - /data/coolify/applications/music-library:/mnt/music_library
    entrypoint: /usr/local/bin/litestream
    command: replicate -config /opt/litestream/litestream.yaml
    healthcheck:
      test: ["CMD", "litestream", "databases", "-config", "/opt/litestream/litestream.yaml"]
      interval: 30s
      timeout: 10s
      retries: 3
    environment:
      - LITESTREAM_ACCESS_KEY_ID
      - LITESTREAM_SECRET_ACCESS_KEY
configs:
  litestream:
    content: |
      dbs:
        - path: /mnt/music_library/music_library_prod.db
          replica:
            type: s3
            name: music_library_prod
            bucket: ffmusiclibrary
            path: prod
            endpoint: https://nbg1.your-objectstorage.com
            sync-interval: 60m
            retention: 672h
secrets:
  FLUXON_KEY_FINGERPRINT:
    environment: FLUXON_KEY_FINGERPRINT
  FLUXON_LICENSE_KEY:
    environment: FLUXON_LICENSE_KEY
