Refactor CI workflow to utilize Docker Buildx for building and pushing images
Some checks failed
CI/CD Pipeline / frontend-lint (push) Successful in 1m38s
CI/CD Pipeline / backend-lint (push) Failing after 2m26s
CI/CD Pipeline / backend-build (push) Has been skipped
CI/CD Pipeline / frontend-build (push) Failing after 2m23s
CI/CD Pipeline / e2e-test (push) Has been skipped

- Replace Kaniko with Docker Buildx for frontend and backend builds
- Add steps for setting up Docker Buildx and logging into the container registry
- Enhance caching strategy with cache-from and cache-to options
- Introduce PostgreSQL service for backend testing with health checks
- Include steps to install PostgreSQL client and wait for readiness
This commit is contained in:
Damir Mukimov 2025-12-26 13:38:11 +01:00
parent f7ec8352b9
commit 1a0135fffe
No known key found for this signature in database
GPG Key ID: 42996CC7C73BC750

View File

@ -41,23 +41,59 @@ jobs:
needs: frontend-lint needs: frontend-lint
if: gitea.event_name == 'push' && gitea.ref == 'refs/heads/master' if: gitea.event_name == 'push' && gitea.ref == 'refs/heads/master'
steps: steps:
- uses: actions/checkout@v4 - name: Checkout code
- name: Build and push frontend with Kaniko uses: actions/checkout@v4
uses: aevea/action-kaniko@v0.9.0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver-opts: |
image=moby/buildkit:latest
- name: Login to Container Registry
uses: docker/login-action@v3
with: with:
registry: registry.bk.glpx.pro registry: registry.bk.glpx.pro
username: ${{ secrets.DOCKER_USERNAME }} username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }} password: ${{ secrets.DOCKER_PASSWORD }}
image: turash/turash-frontend
tag: latest,${{ gitea.sha }} - name: Build and push frontend
cache: true uses: docker/build-push-action@v5
cache_registry: registry.bk.glpx.pro/turash/turash-frontend with:
context: bugulma/frontend context: bugulma/frontend
dockerfile: bugulma/frontend/Dockerfile file: bugulma/frontend/Dockerfile
kaniko_executor_image: gcr.io/kaniko-project/executor:debug-v1.24.0 push: true
tags: |
registry.bk.glpx.pro/turash/turash-frontend:latest
registry.bk.glpx.pro/turash/turash-frontend:${{ gitea.sha }}
cache-from: type=registry,ref=registry.bk.glpx.pro/turash/turash-frontend:buildcache
cache-to: type=registry,ref=registry.bk.glpx.pro/turash/turash-frontend:buildcache,mode=max
platforms: linux/amd64
build-args: |
BUILDKIT_INLINE_CACHE=1
backend-lint: backend-lint:
runs-on: ubuntu-latest runs-on: ubuntu-latest
services:
postgres:
image: postgis/postgis:16-3.4
env:
POSTGRES_USER: turash
POSTGRES_PASSWORD: turash123
POSTGRES_DB: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
env:
POSTGRES_HOST: localhost
POSTGRES_PORT: 5432
POSTGRES_USER: turash
POSTGRES_PASSWORD: turash123
POSTGRES_DB: postgres
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Set up Go - name: Set up Go
@ -158,6 +194,25 @@ jobs:
CGO_ENABLED: 0 CGO_ENABLED: 0
GOPROXY: https://proxy.golang.org,direct GOPROXY: https://proxy.golang.org,direct
GOSUMDB: sum.golang.org GOSUMDB: sum.golang.org
- name: Install PostgreSQL client
run: |
apt-get update -qq
DEBIAN_FRONTEND=noninteractive apt-get install -y -qq postgresql-client || true
continue-on-error: true
- name: Wait for PostgreSQL to be ready
run: |
echo "Waiting for PostgreSQL to be ready..."
for i in {1..30}; do
if pg_isready -h localhost -p 5432 -U turash 2>/dev/null || nc -z localhost 5432 2>/dev/null; then
echo "PostgreSQL is ready!"
exit 0
fi
echo "PostgreSQL is unavailable - attempt $i/30"
sleep 2
done
echo "PostgreSQL did not become ready in time"
exit 1
continue-on-error: true
- name: Test - name: Test
working-directory: bugulma/backend working-directory: bugulma/backend
run: | run: |
@ -183,20 +238,36 @@ jobs:
needs: backend-lint needs: backend-lint
if: gitea.event_name == 'push' && gitea.ref == 'refs/heads/master' if: gitea.event_name == 'push' && gitea.ref == 'refs/heads/master'
steps: steps:
- uses: actions/checkout@v4 - name: Checkout code
- name: Build and push backend with Kaniko uses: actions/checkout@v4
uses: aevea/action-kaniko@v0.9.0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver-opts: |
image=moby/buildkit:latest
- name: Login to Container Registry
uses: docker/login-action@v3
with: with:
registry: registry.bk.glpx.pro registry: registry.bk.glpx.pro
username: ${{ secrets.DOCKER_USERNAME }} username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }} password: ${{ secrets.DOCKER_PASSWORD }}
image: turash/turash-backend
tag: latest,${{ gitea.sha }} - name: Build and push backend
cache: true uses: docker/build-push-action@v5
cache_registry: registry.bk.glpx.pro/turash/turash-backend with:
context: bugulma/backend context: bugulma/backend
dockerfile: bugulma/backend/Dockerfile file: bugulma/backend/Dockerfile
kaniko_executor_image: gcr.io/kaniko-project/executor:debug-v1.24.0 push: true
tags: |
registry.bk.glpx.pro/turash/turash-backend:latest
registry.bk.glpx.pro/turash/turash-backend:${{ gitea.sha }}
cache-from: type=registry,ref=registry.bk.glpx.pro/turash/turash-backend:buildcache
cache-to: type=registry,ref=registry.bk.glpx.pro/turash/turash-backend:buildcache,mode=max
platforms: linux/amd64
build-args: |
BUILDKIT_INLINE_CACHE=1
e2e-test: e2e-test:
runs-on: ubuntu-latest runs-on: ubuntu-latest