karlomikus / vue-salt-rim

Salt Rim is a Vue based web client used for connecting to Bar Assistant server instance.
https://barassistant.app
MIT License
104 stars 17 forks source link

MEILISEARCH_URL not respected for add ingredient to cocktail "multi-search" #162

Closed kmaid closed 6 months ago

kmaid commented 8 months ago

I have been working to get the entire Bar Assistant stack under a single domain using Trafik rather than NGIX for SSL etc. I have succeeded however I have had to put in a hack for ingredient lookup to work as Salt Rim searches bar.[domain] rather than bar.[domain]/search as I have specified in the docker compose below.

version: "3.8"

services:
  redis:
    image: redis
    container_name: bar-redis
    environment:
      - ALLOW_EMPTY_PASSWORD=yes
    restart: unless-stopped
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
      interval: 1s
      timeout: 3s
      retries: 30
    networks:
      - default

  meilisearch:
    image: getmeili/meilisearch:v1.4
    container_name: bar-meilisearch
    environment:
      - MEILI_MASTER_KEY=${MEILI_MASTER_KEY}
      - MEILI_ENV=production
    restart: unless-stopped
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:7700"]
      interval: 10s
      timeout: 5s
      retries: 5
    labels:
      - traefik.enable=true
      - traefik.http.routers.meilisearch.entrypoints=web,websecure
      - traefik.http.routers.meilisearch.rule=Host(`bar.${DOMAIN_NAME}`) && (PathPrefix(`/search`) || Path(`/multi-search`)) # hack. 
      - traefik.http.routers.meilisearch.tls=true
      - traefik.http.routers.meilisearch.tls.certresolver=myresolver
      - traefik.http.middlewares.meilisearch-strip.stripprefix.prefixes=/search
      - traefik.http.routers.meilisearch.middlewares=meilisearch-strip

    volumes:
      - /var/media-server/bar/melisearch:/meili_data
    networks:
      - web

  bar-assistant:
    image: barassistant/server:v3
    container_name: bar-server
    depends_on:
      meilisearch:
        condition: service_healthy
      redis:
        condition: service_healthy
    environment:
      - APP_URL=https://bar.${DOMAIN_NAME}/server
      - LOG_CHANNEL=stderr
      - MEILISEARCH_KEY=$MEILI_MASTER_KEY
      - MEILISEARCH_HOST=http://bar-meilisearch:7700
      - REDIS_HOST=bar-redis
      - ALLOW_REGISTRATION=false
    labels:
      - traefik.enable=true
      - traefik.http.routers.bar-server.entrypoints=web,websecure
      - traefik.http.routers.bar-server.rule=Host(`bar.${DOMAIN_NAME}`) && PathPrefix(`/server`)
      - traefik.http.routers.bar-server.tls=true
      - traefik.http.routers.bar-server.tls.certresolver=myresolver
      - traefik.http.middlewares.bar-server-strip.stripprefix.prefixes=/server
      - traefik.http.routers.bar-server.middlewares=bar-server-strip
    restart: unless-stopped
    # healthcheck:
    #   test: ["CMD", "curl", "-f", "http://localhost:3000"]
    #   interval: 10s
    #   timeout: 5s
    #   retries: 5
    volumes:
      - /var/media-server/bar/bar-assistant:/var/www/cocktails/storage/bar-assistant
    networks:
      - web
      - default

  salt-rim:
    image: barassistant/salt-rim:v2
    container_name: bar-web
    environment:
      - API_URL=https://bar.${DOMAIN_NAME}/server
      - MEILISEARCH_URL=https://bar.${DOMAIN_NAME}/search
      - DEFAULT_LOCALE=en-GB
    restart: unless-stopped
    labels:
      - traefik.enable=true
      - traefik.http.routers.bar-web.entrypoints=web,websecure
      - traefik.http.routers.bar-web.rule=Host(`bar.${DOMAIN_NAME}`)
      - traefik.http.routers.bar-web.tls=true
      - traefik.http.routers.bar-web.tls.certresolver=myresolver
      - traefik.http.services.bar-web.loadbalancer.server.port=8080
      - homepage.group=Media
      - homepage.weight=5
      - homepage.name=Bar Assistant
      - homepage.icon=bar-assistant.png
      - homepage.href=https://bar.${DOMAIN_NAME}
      - homepage.description=Cocktail recipes and ingredients database
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:8080"]
      interval: 10s
      timeout: 5s
      retries: 5
    networks:
      - web

networks:
  default:
    name: bar
  web:
    external: true
karlomikus commented 8 months ago

With your current setup, you meilisearch instance should be working and available on /search endpoint. Saltrim will then do requests to /search/multi-search as it should. Make sure your .env file is also updated.

Maybe easier approach would be to put api and search into subdomains, like search.domain.com and api.domain.com.