🔧 enhance Makefile and Readme with Docker Swarm and Kubernetes support, adding new targets for deployment and management
This commit is contained in:
137
compose.swarm.yml
Normal file
137
compose.swarm.yml
Normal file
@@ -0,0 +1,137 @@
|
||||
# Docker Swarm stack - run: make swarm-deploy (build images first: make swarm-build)
|
||||
# Postgres is pinned to manager node so its volume stays on one node.
|
||||
|
||||
services:
|
||||
api:
|
||||
image: handheld-devices-api:latest
|
||||
networks:
|
||||
- handheld-net
|
||||
ports:
|
||||
- "8080:8080"
|
||||
env_file:
|
||||
- .env
|
||||
environment:
|
||||
DB_HOST: postgres
|
||||
DB_PORT: "5432"
|
||||
DB_NAME: handheld_devices
|
||||
DB_USER: devices_user
|
||||
DB_PASSWORD: devices_password
|
||||
REDIS_HOST: redis
|
||||
REDIS_PORT: "6379"
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "wget -q -O - http://localhost:8080/health/live || exit 1"]
|
||||
interval: 5s
|
||||
timeout: 5s
|
||||
retries: 10
|
||||
start_period: 30s
|
||||
deploy:
|
||||
replicas: 2
|
||||
restart_policy:
|
||||
condition: on-failure
|
||||
update_config:
|
||||
parallelism: 1
|
||||
delay: 10s
|
||||
|
||||
postgres:
|
||||
image: postgres:15-alpine
|
||||
networks:
|
||||
- handheld-net
|
||||
ports:
|
||||
- "5432:5432"
|
||||
environment:
|
||||
POSTGRES_DB: handheld_devices
|
||||
POSTGRES_USER: devices_user
|
||||
POSTGRES_PASSWORD: devices_password
|
||||
volumes:
|
||||
- postgres_data:/var/lib/postgresql/data
|
||||
configs:
|
||||
- source: postgres_init
|
||||
target: /docker-entrypoint-initdb.d/001_create_devices.sql
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U devices_user -d handheld_devices"]
|
||||
interval: 5s
|
||||
timeout: 3s
|
||||
retries: 10
|
||||
deploy:
|
||||
replicas: 1
|
||||
restart_policy:
|
||||
condition: on-failure
|
||||
placement:
|
||||
constraints:
|
||||
- node.labels.db == true
|
||||
|
||||
redis:
|
||||
image: redis:7-alpine
|
||||
networks:
|
||||
- handheld-net
|
||||
ports:
|
||||
- "6379:6379"
|
||||
healthcheck:
|
||||
test: ["CMD", "redis-cli", "ping"]
|
||||
interval: 5s
|
||||
timeout: 3s
|
||||
retries: 5
|
||||
deploy:
|
||||
replicas: 1
|
||||
restart_policy:
|
||||
condition: on-failure
|
||||
|
||||
frontend:
|
||||
image: handheld-devices-frontend:latest
|
||||
networks:
|
||||
- handheld-net
|
||||
ports:
|
||||
- "8090:8090"
|
||||
env_file:
|
||||
- .env
|
||||
environment:
|
||||
API_URL: http://localhost:8080
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "wget -q -O - http://localhost:8090/health || exit 1"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 3
|
||||
start_period: 5s
|
||||
deploy:
|
||||
replicas: 1
|
||||
restart_policy:
|
||||
condition: on-failure
|
||||
update_config:
|
||||
parallelism: 1
|
||||
delay: 10s
|
||||
|
||||
worker:
|
||||
image: handheld-devices-worker:latest
|
||||
networks:
|
||||
- handheld-net
|
||||
env_file:
|
||||
- .env
|
||||
environment:
|
||||
DB_HOST: postgres
|
||||
DB_PORT: "5432"
|
||||
DB_NAME: handheld_devices
|
||||
DB_USER: devices_user
|
||||
DB_PASSWORD: devices_password
|
||||
REDIS_HOST: redis
|
||||
REDIS_PORT: "6379"
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pgrep -f 'worker.lua' || exit 1"]
|
||||
interval: 10s
|
||||
timeout: 3s
|
||||
retries: 3
|
||||
deploy:
|
||||
replicas: 1
|
||||
restart_policy:
|
||||
condition: on-failure
|
||||
|
||||
configs:
|
||||
postgres_init:
|
||||
file: ./devices-api/migrations/001_create_devices.sql
|
||||
|
||||
volumes:
|
||||
postgres_data:
|
||||
|
||||
networks:
|
||||
handheld-net:
|
||||
driver: overlay
|
||||
attachable: true
|
||||
Reference in New Issue
Block a user