services:
  vikunja:
    image: vikunja/vikunja:latest
    container_name: vikunja
    environment:
      - VIKUNJA_DATABASE_TYPE=postgres
      - VIKUNJA_DATABASE_HOST=vikunja-db
      - VIKUNJA_DATABASE_DATABASE=vikunja
      - VIKUNJA_DATABASE_USER=vikunja
      - VIKUNJA_DATABASE_PASSWORD=${VIKUNJA_DB_PASSWORD}
      - VIKUNJA_REDIS_ENABLED=true
      - VIKUNJA_REDIS_HOST=vikunja-redis:6379
      - VIKUNJA_SERVICE_PUBLICURL=${VIKUNJA_PUBLIC_URL}
      - VIKUNJA_SERVICE_TIMEZONE=America/New_York
      - VIKUNJA_SERVICE_ENABLEREGISTRATION=false
      - VIKUNJA_SERVICE_ENABLEEMAILREMINDERS=true
      - VIKUNJA_MAILER_ENABLED=true
      - VIKUNJA_MAILER_HOST=${SMTP_HOST}
      - VIKUNJA_MAILER_PORT=${SMTP_PORT}
      - VIKUNJA_MAILER_USERNAME=${SMTP_USER}
      - VIKUNJA_MAILER_PASSWORD=${SMTP_PASSWORD}
      - VIKUNJA_MAILER_FROMEMAIL=${SMTP_FROM}
      - VIKUNJA_BACKGROUNDS_ENABLED=true
      - VIKUNJA_BACKGROUNDS_PROVIDERS_UNSPLASH_ENABLED=true
      - VIKUNJA_BACKGROUNDS_PROVIDERS_UNSPLASH_ACCESSTOKEN=${UNSPLASH_ACCESS_TOKEN}
      - VIKUNJA_DEFAULTSETTINGS_WEEK_START=1
      - VIKUNJA_DEFAULTSETTINGS_TIMEZONE=America/New_York
      - VIKUNJA_METRICS_ENABLED=true
      - VIKUNJA_LOG_LEVEL=info
    volumes:
      - ${APPDATA}/vikunja/files:/app/vikunja/files
    ports:
      - "3456:3456"
    networks:
      - vikunja-internal
    depends_on:
      vikunja-db:
        condition: service_healthy
      vikunja-redis:
        condition: service_healthy
    restart: unless-stopped

  vikunja-db:
    image: postgres:16-alpine
    container_name: vikunja-db
    environment:
      - POSTGRES_DB=vikunja
      - POSTGRES_USER=vikunja
      - POSTGRES_PASSWORD=${VIKUNJA_DB_PASSWORD}
    volumes:
      - ${APPDATA}/vikunja/db:/var/lib/postgresql/data
    networks:
      - vikunja-internal
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U vikunja"]
      interval: 10s
      timeout: 5s
      retries: 5
    restart: unless-stopped

  vikunja-redis:
    image: redis:7-alpine
    container_name: vikunja-redis
    command: redis-server --appendonly yes
    volumes:
      - ${APPDATA}/vikunja/redis:/data
    networks:
      - vikunja-internal
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
      interval: 10s
      timeout: 5s
      retries: 5
    restart: unless-stopped

networks:
  vikunja-internal:
    name: vikunja-internal
