Skip to content

Commit

Permalink
added healthchecks to containers and fixed deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
vvalerio-priv committed Mar 5, 2024
1 parent 49efc23 commit adda1d8
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 28 deletions.
20 changes: 20 additions & 0 deletions cmd/methods/createfunctions.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,32 @@ func CreateEnvironment(env string, dockercomposefile string, externalip string,
"--env-file="+env,
"up",
"-d",
"--wait",
"--build",
"rabbitmq")); err != nil {
PrintError("Creation of rabbitmq container failed, cause: " + err.Error())
return err
}

time.Sleep(15 * time.Second)

PrintTask("Installing metadata catalogue container on the machine")

if err := ExecuteCommand(exec.Command("docker-compose",
"-f",
dockercomposefile,
"--env-file="+env,
"up",
"-d",
"--wait",
"--build",
"metadatacatalogue")); err != nil {
PrintError("Creation of metadata catalogue container failed, cause: " + err.Error())
return err
}

time.Sleep(15 * time.Second)

PrintTask("Installing all remaining containers on the machine")

if err := ExecuteCommand(exec.Command("docker-compose",
Expand All @@ -129,6 +148,7 @@ func CreateEnvironment(env string, dockercomposefile string, externalip string,
"--env-file="+env,
"up",
"-d",
"--wait",
"--build")); err != nil {
PrintError("Creation of container failed, cause: " + err.Error())
return err
Expand Down
70 changes: 42 additions & 28 deletions cmd/methods/docker-compose/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,14 @@ services:
- SECURITY_KEY=${SECURITY_KEY}
- AAI_SERVICE_ENDPOINT=${AAI_SERVICE_ENDPOINT}
depends_on:
- rabbitmq
- resources
- backoffice
- ingestor
- externalaccess
resources:
condition: service_healthy
backoffice:
condition: service_healthy
ingestor:
condition: service_healthy
externalaccess:
condition: service_healthy
rabbitmq:
image: "${MESSAGE_BUS_IMAGE}"
container_name: ${PREFIX}rabbitmq
Expand All @@ -63,6 +66,11 @@ services:
- RABBITMQ_DEFAULT_PASS=${BROKER_USERNAME}
- RABBITMQ_DEFAULT_USER=${BROKER_PASSWORD}
- RABBITMQ_DEFAULT_VHOST=${BROKER_VHOST}
healthcheck:
test: rabbitmq-diagnostics -q ping
interval: 30s
timeout: 10s
retries: 10
networks:
- epos_network
resources:
Expand Down Expand Up @@ -93,13 +101,13 @@ services:
- CONNECTION_POOL_MIN_SIZE=${CONNECTION_POOL_MIN_SIZE}
- CONNECTION_POOL_MAX_SIZE=${CONNECTION_POOL_MAX_SIZE}
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/api/resources-service/v1/actuator/health"]
interval: 1m30s
test: "curl --fail --silent http://localhost:8080/api/resources-service/v1/actuator/health | grep UP || exit 1"
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
retries: 10
depends_on:
- rabbitmq
metadatacatalogue:
condition: service_healthy
backoffice:
image: "${DOCKER_REGISTRY}/${BACKOFFICE_SERVICE_IMAGE}"
container_name: ${PREFIX}backoffice-service
Expand All @@ -116,13 +124,13 @@ services:
- CONNECTION_POOL_MIN_SIZE=${CONNECTION_POOL_MIN_SIZE}
- CONNECTION_POOL_MAX_SIZE=${CONNECTION_POOL_MAX_SIZE}
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/api/backoffice-service/v1/actuator/health"]
interval: 1m30s
test: "curl --fail --silent http://localhost:8080/api/backoffice-service/v1/actuator/health | grep UP || exit 1"
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
retries: 10
depends_on:
- rabbitmq
metadatacatalogue:
condition: service_healthy
ingestor:
image: "${DOCKER_REGISTRY}/${INGESTOR_IMAGE}"
container_name: ${PREFIX}ingestor-service
Expand All @@ -144,13 +152,13 @@ services:
- CONNECTION_POOL_MIN_SIZE=${CONNECTION_POOL_MIN_SIZE}
- CONNECTION_POOL_MAX_SIZE=${CONNECTION_POOL_MAX_SIZE}
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/api/ingestor-service/v1/actuator/health"]
interval: 1m30s
test: "curl --fail --silent http://localhost:8080/api/ingestor-service/v1/actuator/health | grep UP || exit 1"
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
retries: 10
depends_on:
- rabbitmq
metadatacatalogue:
condition: service_healthy
externalaccess:
image: "${DOCKER_REGISTRY}/${EXTERNAL_ACCESS_IMAGE}"
container_name: ${PREFIX}external-access-service
Expand All @@ -177,13 +185,15 @@ services:
- CONNECTION_POOL_MIN_SIZE=${CONNECTION_POOL_MIN_SIZE}
- CONNECTION_POOL_MAX_SIZE=${CONNECTION_POOL_MAX_SIZE}
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/api/external-access-service/v1/actuator/health"]
interval: 1m30s
test: "curl --fail --silent http://localhost:8080/api/external-access-service/v1/actuator/health | grep UP || exit 1"
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
retries: 10
depends_on:
- rabbitmq
metadatacatalogue:
condition: service_healthy
rabbitmq:
condition: service_healthy
converter:
image: "${DOCKER_REGISTRY}/${CONVERTER_IMAGE}"
container_name: ${PREFIX}converter-service
Expand All @@ -207,7 +217,8 @@ services:
- CONNECTION_POOL_MIN_SIZE=${CONNECTION_POOL_MIN_SIZE}
- CONNECTION_POOL_MAX_SIZE=${CONNECTION_POOL_MAX_SIZE}
depends_on:
- rabbitmq
rabbitmq:
condition: service_healthy
metadatacatalogue:
restart: always
image: "${DOCKER_REGISTRY}/${METADATA_DB_IMAGE}"
Expand All @@ -218,8 +229,11 @@ services:
- POSTGRES_DB=${POSTGRES_DB}
volumes:
- psqldata:/var/lib/postgresql
depends_on:
- rabbitmq
healthcheck:
test: ["CMD-SHELL","pg_isready"]
interval: 30s
timeout: 10s
retries: 10
networks:
- epos_network
volumes:
Expand Down

0 comments on commit adda1d8

Please sign in to comment.