Skip to content

hotfix: add networks docker compose file. #83

hotfix: add networks docker compose file.

hotfix: add networks docker compose file. #83

Workflow file for this run

name: Docker Image CI/CD
on:
push:
branches: [ 'master' ]
# pull_request:
# branches: ['master']
jobs:
build:
runs-on: [ self-hosted, linux, x64, backend ]
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Log in to Docker Hub
run: echo "${{ secrets.DOCKER_HUB_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_HUB_USERNAME }}" --password-stdin
- name: Build and push Docker image
run: |
docker-compose -f docker-compose.build.yml build
docker-compose -f docker-compose.build.yml push
deploy:
runs-on: [ self-hosted, linux, x64, backend ]
needs: build
environment: Production
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Deploy
env:
DB_DATABASE: ${{ secrets.DB_DATABASE }}
DB_DATABASE_TEST: ${{ secrets.DB_DATABASE_TEST }}
DB_ROOT_PASSWORD: ${{ secrets.DB_ROOT_PASSWORD }}
DB_LOCAL_PORT: ${{ secrets.DB_LOCAL_PORT }}
DB_USER: ${{ secrets.DB_USER }}
DB_DOCKER_PORT: ${{ secrets.DB_DOCKER_PORT }}
SERVER_LOCAL_PORT: ${{ secrets.SERVER_LOCAL_PORT }}
SERVER_DOCKER_PORT: ${{ secrets.SERVER_DOCKER_PORT }}
SPRING_PROFILES_ACTIVE: ${{ secrets.SPRING_PROFILES_ACTIVE }}
SPRING_DATASOURCE_URL: ${{ secrets.SPRING_DATASOURCE_URL }}
API_SECURITY_ISSUER: ${{ secrets.API_SECURITY_ISSUER }}
API_SECURITY_TOKEN_SECRET: ${{ secrets.API_SECURITY_TOKEN_SECRET }}
SPRING_MAIL_USERNAME: ${{ secrets.SPRING_MAIL_USERNAME }}
SPRING_MAIL_PASSWORD: ${{ secrets.SPRING_MAIL_PASSWORD }}
EMAIL_TO_SEND_LIST: ${{ secrets.EMAIL_TO_SEND_LIST }}
run: |
docker-compose pull
docker-compose up -d
notify:
runs-on: [ self-hosted, linux, x64, backend ]
needs: deploy
steps:
- name: Notify deployment
run: echo "Deployment completed successfully"
health-check:
runs-on: [ self-hosted, linux, x64, backend ]
needs: deploy
steps:
- name: Wait for server to be ready and healthy test
run: |
sleep 20
until curl -sSf http://localhost:${{ secrets.SERVER_LOCAL_PORT }}/actuator/health; do
echo "Waiting for server..."
sleep 5
done
cleanup:
runs-on: [ self-hosted, linux, x64, backend ]
needs: health-check
steps:
- name: Set execute permission for cleanup script
run: chmod +x ./.github/scripts/cleanup_docker.sh
- name: Running scripts
run: ./.github/scripts/cleanup_docker.sh