services:
  linkwarden:
    image: ${LINKS_DOCKER_IMAGE}
    container_name: ${LINKS_COMPOSE_PROJECT_NAME}_app
    restart: unless-stopped
    networks:
      - compose_network
    environment:
      TZ: ${TIMEZONE:-Europe/Amsterdam}
      DATABASE_URL: postgresql://${DB_USER}:${DB_PASSWORD}@${CORE_DB_HOST}:${CORE_DB_PORT}/${LINKS_DB_NAME}
      NEXTAUTH_SECRET: ${LINKS_NEXTAUTH_SECRET}
      NEXTAUTH_URL: https://${LINKS_TRAEFIK_HOST}
      MEILI_ADDR: http://linkwarden_meilisearch:7700
      MEILI_MASTER_KEY: ${LINKS_MEILI_MASTER_KEY}
      EMAIL_FROM: ${EMAIL_FROM}
      EMAIL_SERVER: smtp://${EMAIL_SMTP_USER}:${EMAIL_SMTP_PASSWORD}@${EMAIL_SMTP_HOST}:${EMAIL_SMTP_PORT}
    volumes:
      - linkwarden_data:/data/data
    depends_on:
      - linkwarden_meilisearch
    labels:
      - 'traefik.enable=${LINKS_TRAEFIK_ENABLED:-true}'
      - 'traefik.http.middlewares.${LINKS_COMPOSE_PROJECT_NAME}-redirect-web-secure.redirectscheme.scheme=https'
      - 'traefik.http.routers.${LINKS_COMPOSE_PROJECT_NAME}-web.middlewares=${LINKS_COMPOSE_PROJECT_NAME}-redirect-web-secure'
      - 'traefik.http.routers.${LINKS_COMPOSE_PROJECT_NAME}-web.rule=Host(`${LINKS_TRAEFIK_HOST}`)'
      - 'traefik.http.routers.${LINKS_COMPOSE_PROJECT_NAME}-web.entrypoints=web'
      - 'traefik.http.routers.${LINKS_COMPOSE_PROJECT_NAME}-web-secure.rule=Host(`${LINKS_TRAEFIK_HOST}`)'
      - 'traefik.http.routers.${LINKS_COMPOSE_PROJECT_NAME}-web-secure.tls.certresolver=resolver'
      - 'traefik.http.routers.${LINKS_COMPOSE_PROJECT_NAME}-web-secure.entrypoints=web-secure'
      - 'traefik.http.middlewares.${LINKS_COMPOSE_PROJECT_NAME}-web-secure-compress.compress=true'
      - 'traefik.http.routers.${LINKS_COMPOSE_PROJECT_NAME}-web-secure.middlewares=${LINKS_COMPOSE_PROJECT_NAME}-web-secure-compress'
      - 'traefik.http.services.${LINKS_COMPOSE_PROJECT_NAME}-web-secure.loadbalancer.server.port=3000'
      - 'traefik.docker.network=${NETWORK_NAME}'
      - 'com.centurylinklabs.watchtower.enable=true'

  linkwarden_meilisearch:
    image: ${LINKS_MEILI_IMAGE}
    container_name: ${LINKS_COMPOSE_PROJECT_NAME}_meilisearch
    restart: unless-stopped
    networks:
      - compose_network
    environment:
      MEILI_MASTER_KEY: ${LINKS_MEILI_MASTER_KEY}
      MEILI_NO_ANALYTICS: ${LINKS_MEILI_NO_ANALYTICS:-true}
    volumes:
      - linkwarden_meili_data:/meili_data

volumes:
  linkwarden_data:
    name: ${LINKS_COMPOSE_PROJECT_NAME}_data
  linkwarden_meili_data:
    name: ${LINKS_COMPOSE_PROJECT_NAME}_meili_data
