Commit 89610bdf authored by Noel Alonso's avatar Noel Alonso
Browse files

Unifica variables de puerto y mueve healthcheck

Ahora todos tienen el mismo puerto, por lo que no es necesario tener dos
variables diferenciadas.

Se pasa el healthcheck del docker-compose de cada componente al
Dockerfile diferenciando el componente por variable
parent 7d66df24
Loading
Loading
Loading
Loading
+13 −3
Original line number Diff line number Diff line
ARG PARENT_IMAGE_NAME
ARG PARENT_IMAGE_TAG
ARG PARENT_IMAGE_NAME=registry.gitlab.com/redmic-project/docker/redmic-server
ARG PARENT_IMAGE_TAG=latest

FROM ${PARENT_IMAGE_NAME}:${PARENT_IMAGE_TAG}

ARG PORT=8080

COPY /*/dist/*.jar ./

EXPOSE ${COMMANDS_PORT} ${VIEW_PORT}
ARG PORT=8080
EXPOSE ${PORT}

HEALTHCHECK \
	--interval=30s \
	--timeout=15s \
	--start-period=3m \
	--retries=10 \
CMD wget --spider -q http://localhost:${PORT}/api/${UNIT_NAME}/${MICROSERVICE_PATH}/actuator/health
+1 −2
Original line number Diff line number Diff line
UNIT_NAME=template
COMMANDS_PORT=port1
VIEW_PORT=port2
PORT=8080
+5 −9
Original line number Diff line number Diff line
@@ -2,9 +2,11 @@ version: '3.5'

services:
  template-commands:
    image: ${IMAGE_NAME}:${IMAGE_TAG:-latest}
    image: ${IMAGE_NAME:-registry.gitlab.com/redmic-project/server/template/functional-unit-template}:${IMAGE_TAG:-latest}
    environment:
      - COMMANDS_PORT
      - UNIT_NAME
      - MICROSERVICE_PATH=commands
      - PORT
      - SPRING_PROFILES_ACTIVE
      - MICROSERVICE_NAME=${UNIT_NAME}-commands
      - SPRING_KAFKA_CLIENT-ID={{.Service.Name}}-{{.Task.Slot}}
@@ -16,19 +18,13 @@ services:
      - traefik-net
    volumes:
      - commands-vol:/tmp/kafka
    healthcheck:
      test: wget --spider -q http://localhost:${COMMANDS_PORT}/api/${UNIT_NAME}/commands/actuator/health
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 2m
    deploy:
      mode: replicated
      replicas: 1
      labels:
        traefik.frontend.rule: Host:${PUBLIC_HOSTNAME};PathPrefix:/api/${UNIT_NAME}/commands
        traefik.backend: ${UNIT_NAME}-commands
        traefik.port: '${COMMANDS_PORT}'
        traefik.port: '${PORT}'
      restart_policy:
        delay: 10s
        window: 3m
+5 −9
Original line number Diff line number Diff line
@@ -2,9 +2,11 @@ version: '3.5'

services:
  template-view:
    image: ${IMAGE_NAME}:${IMAGE_TAG:-latest}
    image: ${IMAGE_NAME:-registry.gitlab.com/redmic-project/server/template/functional-unit-template}:${IMAGE_TAG:-latest}
    environment:
      - VIEW_PORT
      - UNIT_NAME
      - MICROSERVICE_PATH=view
      - PORT
      - SPRING_PROFILES_ACTIVE
      - MICROSERVICE_NAME=${UNIT_NAME}-view
      - SPRING_KAFKA_CLIENT-ID={{.Service.Name}}-{{.Task.Slot}}
@@ -14,19 +16,13 @@ services:
      - kafka-net
      - redmic-net
      - traefik-net
    healthcheck:
      test: wget --spider -q http://localhost:${VIEW_PORT}/api/${UNIT_NAME}/view/actuator/health
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 2m
    deploy:
      mode: replicated
      replicas: 1
      labels:
        traefik.frontend.rule: Host:${PUBLIC_HOSTNAME};PathPrefix:/api/${UNIT_NAME}/view
        traefik.backend: ${UNIT_NAME}-view
        traefik.port: '${VIEW_PORT}'
        traefik.port: '${PORT}'
      restart_policy:
        delay: 10s
        window: 3m