services:
  linkwarden:
    extends:
      file: ${TEMPLATES_PATH}
      service: default
    image: ghcr.io/linkwarden/linkwarden:v2.14.0
    container_name: linkwarden
    ports:
      - 4020:3000
    networks:
      - ip4net
      - ip6net
    volumes:
      - ${SERVICE_PATH}/linkwarden/data:/data/data
    environment:
      - DATABASE_URL=postgresql://linkwarden:${LINKWARDEN_DATABASE_PASSWORD}@postgres:5432/linkwarden
      - NEXTAUTH_URL=https://linkwarden.${PUBLIC_DOMAIN}/api/v1/auth
      - NEXTAUTH_SECRET=${LINKWARDEN_NEXTAUTH_SECRET}
      - MEILI_MASTER_KEY=${LINKWARDEN_MEILI_MASTER_KEY}
      - MEILI_HOST=http://meilisearch:7700
      - NEXT_PUBLIC_DISABLE_REGISTRATION=true
      - NEXT_PUBLIC_AUTHELIA_ENABLED=true
      - AUTHELIA_WELLKNOWN_URL=https://auth.${PUBLIC_DOMAIN}/.well-known/openid-configuration
      - AUTHELIA_CLIENT_ID=linkwarden
      - AUTHELIA_CLIENT_SECRET=${LINKWARDEN_OIDC_CLIENT_SECRET}
    labels:
      # Traefik
      - "traefik.enable=true"
      - "traefik.http.routers.linkwarden.rule=Host(`linkwarden.${PUBLIC_DOMAIN}`)"
      - "traefik.http.routers.linkwarden.entrypoints=https"
      - "traefik.http.routers.linkwarden.tls=true"

  meilisearch:
    extends:
      file: ${TEMPLATES_PATH}
      service: default
    image: getmeili/meilisearch:v1.31.0
    container_name: linkwarden_meili
    networks:
      - ip4net
      - ip6net
    ports:
      - 4021:7700
    environment:
      - MEILI_MASTER_KEY=${LINKWARDEN_MEILI_MASTER_KEY}
    volumes:
      - ${SERVICE_PATH}/linkwarden/meili_data:/meili_data
    # command:
    #   [
    #     "--master-key=${LINKWARDEN_MEILI_MASTER_KEY}",
    #     "--env=production",
    #     "--import-dump=${SERVICE_PATH}/linkwarden/meili_data/dumps/20260115-183317235.dump",
    #   ]
