Add healthcheck endpoints and scripts
This commit is contained in:
@ -9,19 +9,21 @@ compose-up-d:
|
||||
|
||||
###
|
||||
|
||||
CIVO_SSH:="ssh://ubuntu@212.2.244.220"
|
||||
|
||||
.PHONY: swarm-init
|
||||
swarm-init:
|
||||
docker swarm init
|
||||
DOCKER_HOST=${CIVO_SSH} docker swarm init
|
||||
|
||||
.PHONY: swarm-deploy-stack
|
||||
swarm-deploy-stack:
|
||||
docker stack deploy -c stack.yaml example-app
|
||||
DOCKER_HOST=${CIVO_SSH} docker stack deploy -c docker-swarm.yml example-app
|
||||
|
||||
.PHONY: swarm-remove-stack
|
||||
swarm-remove-stack:
|
||||
docker stack rm example-app
|
||||
DOCKER_HOST=${CIVO_SSH} docker stack rm example-app
|
||||
|
||||
.PHONY: create-secrets
|
||||
create-secrets:
|
||||
echo -n "foobarbaz" | docker secret create postgres-passwd -
|
||||
echo -n "postgres://postgres:foobarbaz@db:5432/postgres" | docker secret create database-url -
|
||||
echo -n "foobarbaz" | DOCKER_HOST=${CIVO_SSH} docker secret create postgres-passwd -
|
||||
echo -n "postgres://postgres:foobarbaz@db:5432/postgres" | DOCKER_HOST=${CIVO_SSH} docker secret create database-url -
|
||||
@ -7,8 +7,14 @@ services:
|
||||
ports:
|
||||
- 80:80
|
||||
restart: unless-stopped
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost/ping"]
|
||||
interval: 30s
|
||||
timeout: 5s
|
||||
retries: 3
|
||||
start_period: 10s
|
||||
api-node:
|
||||
image: sidpalas/devops-directive-docker-course-api-node:7
|
||||
image: sidpalas/devops-directive-docker-course-api-node:8
|
||||
networks:
|
||||
- frontend
|
||||
- backend
|
||||
@ -18,8 +24,14 @@ services:
|
||||
environment:
|
||||
- DATABASE_URL=postgres://postgres:foobarbaz@db:5432/postgres
|
||||
restart: unless-stopped
|
||||
healthcheck:
|
||||
test: ["CMD", "node", "src/healthcheck.js"]
|
||||
interval: 30s
|
||||
timeout: 5s
|
||||
retries: 3
|
||||
start_period: 10s
|
||||
api-golang:
|
||||
image: sidpalas/devops-directive-docker-course-api-golang:6
|
||||
image: sidpalas/devops-directive-docker-course-api-golang:7
|
||||
networks:
|
||||
- frontend
|
||||
- backend
|
||||
@ -29,6 +41,12 @@ services:
|
||||
environment:
|
||||
- DATABASE_URL=postgres://postgres:foobarbaz@db:5432/postgres
|
||||
restart: unless-stopped
|
||||
healthcheck:
|
||||
test: ["CMD", "/healthcheck"]
|
||||
interval: 30s
|
||||
timeout: 5s
|
||||
retries: 3
|
||||
start_period: 10s
|
||||
db:
|
||||
image: postgres:15.1-alpine
|
||||
networks:
|
||||
@ -37,6 +55,11 @@ services:
|
||||
- pgdata:/var/lib/postgresql/data
|
||||
environment:
|
||||
- POSTGRES_PASSWORD=foobarbaz
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
|
||||
volumes:
|
||||
pgdata:
|
||||
|
||||
@ -7,8 +7,14 @@ services:
|
||||
- frontend
|
||||
ports:
|
||||
- 80:80
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost/ping"]
|
||||
interval: 30s
|
||||
timeout: 5s
|
||||
retries: 3
|
||||
start_period: 10s
|
||||
api-node:
|
||||
image: sidpalas/devops-directive-docker-course-api-node:7
|
||||
image: sidpalas/devops-directive-docker-course-api-node:8
|
||||
environment:
|
||||
- DATABASE_URL_FILE=/run/secrets/database-url
|
||||
secrets:
|
||||
@ -18,8 +24,14 @@ services:
|
||||
- backend
|
||||
ports:
|
||||
- 3000:3000
|
||||
healthcheck:
|
||||
test: ["CMD", "node", "/usr/src/app/healthcheck.js"]
|
||||
interval: 30s
|
||||
timeout: 5s
|
||||
retries: 3
|
||||
start_period: 10s
|
||||
api-golang:
|
||||
image: sidpalas/devops-directive-docker-course-api-golang:6
|
||||
image: sidpalas/devops-directive-docker-course-api-golang:7
|
||||
networks:
|
||||
- frontend
|
||||
- backend
|
||||
@ -29,6 +41,12 @@ services:
|
||||
- database-url
|
||||
ports:
|
||||
- 8080:8080
|
||||
healthcheck:
|
||||
test: ["CMD", "/healthcheck"]
|
||||
interval: 30s
|
||||
timeout: 5s
|
||||
retries: 3
|
||||
start_period: 10s
|
||||
db:
|
||||
image: postgres:15.1-alpine
|
||||
networks:
|
||||
@ -41,6 +59,11 @@ services:
|
||||
- POSTGRES_PASSWORD_FILE=/run/secrets/postgres-passwd
|
||||
secrets:
|
||||
- postgres-passwd
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
|
||||
volumes:
|
||||
pgdata:
|
||||
|
||||
Reference in New Issue
Block a user