Skip to content

Commit f1386bc

Browse files
committed
2 parents 3a881a2 + 3da6259 commit f1386bc

2 files changed

Lines changed: 86 additions & 0 deletions

File tree

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Deploy with Docker Compose
2+
on:
3+
push:
4+
branches:
5+
- main
6+
7+
jobs:
8+
deploy:
9+
runs-on: authenticator-backend
10+
11+
steps:
12+
- uses: actions/checkout@v5
13+
with:
14+
fetch-depth: 0
15+
16+
- name: Set up Docker
17+
uses: docker/setup-buildx-action@v3
18+
19+
- name: Deploy containers
20+
env:
21+
ALLOWED_ORIGINS: ${{ secrets.ALLOWED_ORIGINS }}
22+
run: |
23+
echo "🔍 Checking redis container status..."
24+
if docker ps --filter "name=redis" --filter "health=healthy" --format '{{.Names}}' | grep -q '^redis$'; then
25+
echo "✅ Redis container is already healthy. Skipping redis restart."
26+
REDIS_RUNNING=true
27+
else
28+
echo "⚠️ Redis not running or unhealthy. It will be (re)started."
29+
REDIS_RUNNING=false
30+
fi
31+
32+
echo "🚀 Starting deployment..."
33+
if [ "$REDIS_RUNNING" = true ]; then
34+
docker compose -f docker-compose-prod.yml up -d --build --no-deps app
35+
else
36+
docker compose -f docker-compose-prod.yml up -d --build
37+
fi
38+
39+
echo "🧹 Cleaning up unused resources..."
40+
docker system prune -f
41+
42+
- name: Verify containers
43+
run: |
44+
docker ps
45+
echo
46+
echo "📋 Container health statuses:"
47+
docker ps --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}"

docker-compose-prod.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
services:
2+
app:
3+
build: .
4+
container_name: mfa-service
5+
environment:
6+
- NODE_ENV=production
7+
- REDIS_URL=redis://redis:6379
8+
- ALLOWED_ORIGINS=${ALLOWED_ORIGINS:-*}
9+
depends_on:
10+
redis:
11+
condition: service_healthy
12+
restart: unless-stopped
13+
networks:
14+
- mfa-network
15+
- traefik-net
16+
17+
redis:
18+
image: redis:7-alpine
19+
command: redis-server --maxmemory 256mb --maxmemory-policy allkeys-lru
20+
volumes:
21+
- redis-data:/data
22+
healthcheck:
23+
test: ["CMD", "redis-cli", "ping"]
24+
interval: 10s
25+
timeout: 3s
26+
retries: 3
27+
restart: unless-stopped
28+
networks:
29+
- mfa-network
30+
31+
volumes:
32+
redis-data:
33+
34+
networks:
35+
mfa-network:
36+
driver: bridge
37+
38+
traefik-net:
39+
external: true

0 commit comments

Comments
 (0)