Skip to content

Hotfix: timeout edit #23

Hotfix: timeout edit

Hotfix: timeout edit #23

Workflow file for this run

name: CD
on:
push:
branches:
- dev
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: dykkim/muneo
tags: |
type=raw,value=latest
type=sha,format=short
- name: Build and push image
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Copy deploy files to EC2
uses: appleboy/scp-action@v0.1.7
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USERNAME }}
key: ${{ secrets.EC2_SSH_KEY }}
port: ${{ secrets.EC2_PORT }}
source: "docker-compose.yml,nginx/conf.d/default.conf,nginx/conf.d/prod.conf"
target: ${{ secrets.EC2_DEPLOY_PATH }}
strip_components: 0
overwrite: true
- name: Deploy on EC2
uses: appleboy/ssh-action@v1.0.3
env:
DEPLOY_PATH: ${{ secrets.EC2_DEPLOY_PATH }}
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
DOCKERHUB_IMAGE: dykkim/muneo
APP_ENV_PROD: ${{ secrets.APP_ENV_PROD }}
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USERNAME }}
key: ${{ secrets.EC2_SSH_KEY }}
port: ${{ secrets.EC2_PORT }}
envs: DEPLOY_PATH,DOCKERHUB_USERNAME,DOCKERHUB_TOKEN,DOCKERHUB_IMAGE,APP_ENV_PROD
script_stop: true
script: |
set -e
sudo systemctl enable --now docker || true
mkdir -p "${DEPLOY_PATH}"
cd "${DEPLOY_PATH}"
mkdir -p nginx/conf.d
printf "%s" "${APP_ENV_PROD}" > .env
{
echo ""
echo "DOCKERHUB_IMAGE=${DOCKERHUB_IMAGE}"
echo "IMAGE_TAG=latest"
} >> .env
echo "${DOCKERHUB_TOKEN}" | docker login -u "${DOCKERHUB_USERNAME}" --password-stdin
docker compose pull app redis nginx
docker compose up -d --remove-orphans app redis nginx
# Wait until nginx is actually running before exec commands.
for i in {1..30}; do
if docker compose ps --status running nginx | grep -q "nginx"; then
break
fi
sleep 2
done
# Apply updated bind-mounted nginx config without recreating container
docker compose exec -T nginx nginx -t
docker compose exec -T nginx nginx -s reload
# Verify hotfixed directives are present in the running nginx config
docker compose exec -T nginx sh -c "grep -n 'risk-detector\\|proxy_read_timeout\\|proxy_request_buffering' /etc/nginx/conf.d/default.conf || true"
docker image prune -f