services:
  linkwarden:
    environment:
      - NEXTAUTH_SECRET
      - NEXTAUTH_URL
      - DATABASE_URL=postgresql://linkwarden:${POSTGRES_PASSWORD}@postgres:5432/linkwarden
    restart: unless-stopped
    image: ghcr.io/linkwarden/linkwarden:v2.9.3
    ports:
      - 3000
    volumes:
      - linkwarden-data:/data/data
    depends_on:
      - postgres
    healthcheck:
      test: curl --fail http://localhost:3000 || exit 1
      interval: 60s
      retries: 2
      start_period: 60s
      timeout: 15s

  postgres:
    image: postgres:17-alpine
    restart: unless-stopped
    user: postgres
    environment:
      POSTGRES_USER: linkwarden
      POSTGRES_DB: linkwarden
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
    volumes:
      - postgres-data:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready"]
      interval: 10s
      timeout: 5s
      retries: 5

volumes:
  linkwarden-data:
  postgres-data:
