diff --git a/config/env.development b/config/env.development index da9b129a1d..3952d7f860 100644 --- a/config/env.development +++ b/config/env.development @@ -84,6 +84,15 @@ IMAGE_PORT=4444 # Image Service URL IMAGE_URL=http://api.telescope.localhost/v1/image +################################################################################ +# Search Service +################################################################################ + +# Search Service Port (default is 4445) +SEARCH_PORT=4445 + +# Search Service URL +SEARCH_URL=http://api.telescope.localhost/v1/search ################################################################################ # Posts Service diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index b75d77c99a..7e2e3b01b8 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -68,6 +68,34 @@ services: - 'traefik.http.middlewares.strip_auth_prefix.stripprefix.forceSlash=true' - 'traefik.http.routers.auth.middlewares=strip_auth_prefix' + search: + container_name: 'search' + build: + context: ../src/api/search + dockerfile: Dockerfile + environment: + - ELASTIC_APM_SERVICE_NAME=search + - SEARCH_PORT + + - ELASTICSEARCH_HOSTS=http://elasticsearch:9200 + - ELASTIC_APM_SERVER_URL=http://apm:8200 + depends_on: + - elasticsearch + - traefik + ports: + - ${SEARCH_PORT} + labels: + # Enable Traefik + - 'traefik.enable=true' + # Traefik routing for the search service at /v1/search + - 'traefik.http.routers.search.rule=Host(`${API_HOST}`) && PathPrefix(`/${API_VERSION}/search`)' + # Specify the search service port + - 'traefik.http.services.search.loadbalancer.server.port=${SEARCH_PORT}' + # Add middleware to this route to strip the /v1/search prefix + - 'traefik.http.middlewares.strip_search_prefix.stripprefix.prefixes=/${API_VERSION}/search' + - 'traefik.http.middlewares.strip_search_prefix.stripprefix.forceSlash=true' + - 'traefik.http.routers.search.middlewares=strip_search_prefix' + # posts service posts: container_name: 'posts' @@ -164,3 +192,15 @@ services: - 'traefik.http.routers.elasticsearch.rule=Host(`elasticsearch.localhost`)' # Specify the redis port - 'traefik.http.services.elasticsearch.loadbalancer.server.port=9200' + + apm: + image: docker.elastic.co/apm/apm-server:7.10.2 + container_name: 'apm' + restart: unless-stopped + environment: + - ELASTICSEARCH_HOSTS=http://elasticsearch:9200 + - KIBANA_HOST=http://kibana:5601 + ports: + - '8200' + depends_on: + - elasticsearch diff --git a/src/api/docker-compose-api-production.yml b/src/api/docker-compose-api-production.yml deleted file mode 100644 index e29ce99309..0000000000 --- a/src/api/docker-compose-api-production.yml +++ /dev/null @@ -1,207 +0,0 @@ -version: "3" - -services: - # API Gateway - traefik: - image: traefik:v2.4 - container_name: "traefik" - restart: unless-stopped - command: - - "--api.insecure=true" - - "--providers.docker=true" - - "--providers.docker.exposedbydefault=true" - - "--entrypoints.web.address=:80" - - "--entrypoints.websecure.address=:443" - ports: - - "80:80" - - "443:443" - - "8080:8080" - volumes: - - /var/run/docker.sock:/var/run/docker.sock - - # ELK Stack - elasticsearch: - image: docker.elastic.co/elasticsearch/elasticsearch:7.9.3 - container_name: "elasticsearch" - restart: unless-stopped - environment: - - bootstrap.memory_lock=true - - "ES_JAVA_OPTS=-Xms512m -Xmx512m" - - discovery.type=single-node - # See the following: - # - https://www.elastic.co/guide/en/elastic-stack-get-started/current/get-started-docker.html, - # - https://github.com/deviantony/docker-elk/issues/243 - ulimits: - memlock: - soft: -1 - hard: -1 - volumes: - - type: volume - source: elasticsearch - target: /usr/share/elasticsearch/data - ports: - - "9200" - healthcheck: - interval: 20s - retries: 10 - test: curl -s http://localhost:9200/_cluster/health | grep -vq '"status":"red"' - labels: - - "traefik.enable=true" - - "traefik.http.routers.elastic.rule=Host(`elastic.docker.localhost`)" - - "traefik.http.routers.elastic.middlewares=es-stripprefix" - - "traefik.http.middlewares.es-stripprefix.stripprefix.prefixes=/es" - - "traefik.http.services.elastic.loadbalancer.server.port=9200" - - kibana: - image: docker.elastic.co/kibana/kibana:7.9.3 - container_name: "kibana" - restart: unless-stopped - environment: - - ELASTICSEARCH_HOSTS=http://elasticsearch:9200 - - ELASTICSEARCH_URL=http://elasticsearch:9200 - depends_on: - elasticsearch: - condition: service_healthy - volumes: - - type: volume - source: elasticsearch - target: /usr/share/elasticsearch/data - ports: - - "5601" - healthcheck: - interval: 10s - retries: 20 - test: curl --write-out 'HTTP %{http_code}' --fail --silent --output /dev/null http://localhost:5601/api/status - labels: - - "traefik.enable=true" - - "traefik.http.routers.kibana.rule=Host(`kibana.docker.localhost`)" - - "traefik.backend=kibana" - - # System Metrics Logging - metricbeat: - image: docker.elastic.co/beats/metricbeat:7.9.3 - container_name: "metricbeat" - restart: unless-stopped - environment: - - ELASTICSEARCH_HOSTS=http://elasticsearch:9200 - depends_on: - elasticsearch: - condition: service_healthy - - # Logging - filebeat: - image: docker.elastic.co/beats/filebeat:7.10.2 - container_name: "filebeat" - restart: unless-stopped - # Need root for access to Docker daemon at unix:///var/run/docker.sock - user: root - environment: - - ELASTICSEARCH_HOSTS=http://elasticsearch:9200 - - KIBANA_HOST=http://kibana:5601 - volumes: - - ./config/filebeat.yml:/usr/share/filebeat/filebeat.yml:rw - # Allows us to report on docker from the hosts information. - - /var/run/docker.sock:/var/run/docker.sock - # Allows us to load container log path as specified in filebeat.yml - - /var/lib/docker/containers/:/var/lib/docker/containers/:ro - command: filebeat -e -strict.perms=false - depends_on: - elasticsearch: - condition: service_healthy - - # Application Performance Monitoring - apm: - image: docker.elastic.co/apm/apm-server:7.10.2 - container_name: "apm" - restart: unless-stopped - environment: - - ELASTICSEARCH_HOSTS=http://elasticsearch:9200 - - KIBANA_HOST=http://kibana:5601 - ports: - - "8200" - healthcheck: - test: - [ - "CMD", - "curl", - "--write-out", - "'HTTP %{http_code}'", - "--silent", - "--output", - "/dev/null", - "http://apm:8200/healthcheck", - ] - retries: 10 - interval: 10s - depends_on: - elasticsearch: - condition: service_healthy - - # Micro Services - image: - container_name: "image" - restart: unless-stopped - build: - context: ./image - dockerfile: Dockerfile - environment: - - NODE_ENV=production - - IMAGE_PORT=4444 - - SERVICE_NAME=image - - ELASTICSEARCH_HOSTS=http://elasticsearch:9200 - - ELASTIC_APM_SERVER_URL=http://apm:8200 - depends_on: - elasticsearch: - condition: service_healthy - traefik: - condition: service_started - ports: - - "4444" - labels: - # Traefik routing - - "traefik.http.routers.image.rule=Host(`image.docker.localhost`)" - # Enable gzip compression - - "traefik.http.routers.image.middlewares=test-compress" - - "traefik.http.middlewares.test-compress.compress=true" - # ELK Logging - - "co.elastic.logs/json.keys_under_root: true" - - "co.elastic.logs/json.overwrite_keys: true" - - "co.elastic.logs/json.add_error_key: true" - - "co.elastic.logs/json.expand_keys: true" - - "co.elastic.logs/json.message_key: message" - - search: - container_name: "search" - restart: unless-stopped - build: - context: ./search - dockerfile: Dockerfile - environment: - - NODE_ENV=production - - IMAGE_PORT=4445 - - ELASTIC_APM_SERVICE_NAME=search - - - ELASTICSEARCH_HOSTS=http://elasticsearch:9200 - - ELASTIC_APM_SERVER_URL=http://apm:8200 - depends_on: - elasticsearch: - condition: service_healthy - traefik: - condition: service_started - ports: - - "4445" - labels: - # Traefik routing - - "traefik.http.routers.search.rule=Host(`search.docker.localhost`)" - # Enable gzip compression - - "traefik.http.routers.search.middlewares=test-compress" - - "traefik.http.middlewares.test-compress.compress=true" - # ELK Logging - - "co.elastic.logs/json.keys_under_root: true" - - "co.elastic.logs/json.overwrite_keys: true" - - "co.elastic.logs/json.add_error_key: true" - - "co.elastic.logs/json.expand_keys: true" - - "co.elastic.logs/json.message_key: message" - -volumes: - elasticsearch: diff --git a/src/api/search/package.json b/src/api/search/package.json index 6029675ce3..1c93c1d199 100644 --- a/src/api/search/package.json +++ b/src/api/search/package.json @@ -17,7 +17,7 @@ "dependencies": { "@elastic/elasticsearch": "^7.11.0", "@elastic/elasticsearch-mock": "^0.3.0", - "@senecacdot/satellite": "^1.5.2", + "@senecacdot/satellite": "^1.x", "express-validator": "^6.9.2" }, "engines": {