Skip to content

Commit

Permalink
feat: use docker swarm on prod with 3 apps
Browse files Browse the repository at this point in the history
  • Loading branch information
geoje committed Nov 29, 2024
1 parent 650d6c8 commit fbf1ff5
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/be-cd-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -110,5 +110,11 @@ jobs:
key: ${{ secrets.SSH_KEY }}
script: |
cd ~/${{ github.event.repository.name }}
./run-toggle.sh
docker compose pull
STACK_EXISTS=$(docker stack ls --filter name=^${{ secrets.DOCKERHUB_IMAGE_NAME }}$ --format '{{.Name}}')
if [ -z "$STACK_EXISTS" ]; then
docker stack deploy -c docker-compose.yml ${{ secrets.DOCKERHUB_IMAGE_NAME }}
else
docker service update --image ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_IMAGE_NAME }}:prod ${{ secrets.DOCKERHUB_IMAGE_NAME }}_app
fi
docker image prune -af
21 changes: 19 additions & 2 deletions backend/docker/docker-compose-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ services:
TZ: Asia/Seoul
ports:
- 8080:8080
deploy:
replicas: 3
update_config:
parallelism: 1
delay: 10s
order: start-first
restart_policy:
condition: on-failure

db:
image: mysql:8.0.38
Expand All @@ -40,7 +48,16 @@ services:
target: /docker-entrypoint-initdb.d/db-init.sql
healthcheck:
test:
[ "CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "-p${MYSQL_ROOT_PASSWORD}" ]
[
"CMD",
"mysqladmin",
"ping",
"-h",
"localhost",
"-u",
"root",
"-p${MYSQL_ROOT_PASSWORD}",
]
interval: 30s
retries: 5
start_period: 30s
Expand Down Expand Up @@ -148,7 +165,7 @@ configs:
scrape_interval: 15s
static_configs:
- targets: ['app:8080']
- job_name: 'node'
scrape_interval: 15s
static_configs:
Expand Down

0 comments on commit fbf1ff5

Please sign in to comment.