services:
  vikunja:
    image: vikunja/vikunja
    user: "0:0"
    environment:
      VIKUNJA_SERVICE_PUBLICURL: ${VIKUNJA_SERVICE_PUBLICURL}
      VIKUNJA_PUBLIC_PORT: ${VIKUNJA_PUBLIC_PORT}
      VIKUNJA_DATABASE_HOST: ${VIKUNJA_DATABASE_HOST}
      VIKUNJA_DATABASE_PASSWORD: ${VIKUNJA_DATABASE_PASSWORD}
      VIKUNJA_DATABASE_TYPE: ${VIKUNJA_DATABASE_TYPE}
      VIKUNJA_DATABASE_USER: ${VIKUNJA_DATABASE_USER}
      VIKUNJA_DATABASE_DATABASE: ${VIKUNJA_DATABASE_DATABASE}
      VIKUNJA_SERVICE_JWTSECRET: ${VIKUNJA_SERVICE_JWTSECRET}
    ports:
      - 3456
    volumes:
      - vikunja-files:/app/vikunja/files
    depends_on:
      db:
        condition: service_healthy
    restart: unless-stopped

  db:
    image: postgres:17
    environment:
      POSTGRES_PASSWORD: ${VIKUNJA_DATABASE_PASSWORD}
      POSTGRES_USER: ${VIKUNJA_DATABASE_USER}
      POSTGRES_DB: ${VIKUNJA_DATABASE_DATABASE}
    volumes:
      - vikunja-db:/var/lib/postgresql/data
    restart: unless-stopped
    healthcheck:
      test: ["CMD-SHELL", "pg_isready", "-U", "${VIKUNJA_DATABASE_USER}",  "-d", "${VIKUNJA_DATABASE_DATABASE}"]
      interval: 10s
      timeout: 5s
      retries: 3

volumes:
  vikunja-files: {}
  vikunja-db: {}
