Skip to content

Add docker compose and traefik #5

Add docker compose and traefik

Add docker compose and traefik #5

Workflow file for this run

name: Deploy to Production
on:
push:
branches: [ main ]
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Copy files to server
uses: appleboy/scp-action@master
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USERNAME }}
key: ${{ secrets.SERVER_SSH_KEY }}
source: "."
target: "/opt/court-allocation"
- name: Deploy to server
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USERNAME }}
key: ${{ secrets.SERVER_SSH_KEY }}
script: |
cd /opt/court-allocation
# Pull latest changes and rebuild
docker-compose pull || true
docker-compose build --no-cache
# Bring down existing containers
docker-compose down
# Start new containers
docker-compose up -d
# Clean up
docker image prune -f
# Wait for the application to start
echo "Waiting for application to start..."
sleep 10
# Health check
response=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:80)
if [ $response -eq 200 ]; then
echo "Health check passed: Application is running"
else
echo "Health check failed: Application is not responding (Status code: $response)"
exit 1
fi