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

- Replace Kaniko commands with Docker Buildx for frontend and backend builds
- Implement Docker login and setup steps for improved authentication
- Enhance caching strategy by specifying cache-from and cache-to options
- Streamline Dockerfile and context paths for clarity and maintainability
This commit is contained in:
Damir Mukimov 2025-12-26 13:01:29 +01:00
parent 3f25e3a786
commit ab0c778651
No known key found for this signature in database
GPG Key ID: 42996CC7C73BC750

View File

@ -42,22 +42,25 @@ jobs:
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 - uses: actions/checkout@v4
- name: Build and push frontend with Kaniko - name: Set up Docker Buildx
run: | uses: docker/setup-buildx-action@v3
mkdir -p /tmp/kaniko-docker - name: Log in to registry
echo "{\"auths\":{\"registry.bk.glpx.pro\":{\"username\":\"${{ secrets.DOCKER_USERNAME }}\",\"password\":\"${{ secrets.DOCKER_PASSWORD }}\"}}}" > /tmp/kaniko-docker/config.json uses: docker/login-action@v3
docker run --rm \ with:
-v $(pwd):/workspace \ registry: registry.bk.glpx.pro
-v /tmp/kaniko-docker:/kaniko/.docker \ username: ${{ secrets.DOCKER_USERNAME }}
-e DOCKER_CONFIG=/kaniko/.docker \ password: ${{ secrets.DOCKER_PASSWORD }}
gcr.io/kaniko-project/executor:v1.24.0 \ - name: Build and push frontend
--dockerfile=/workspace/bugulma/frontend/Dockerfile \ uses: docker/build-push-action@v5
--context=/workspace/bugulma/frontend \ with:
--destination=registry.bk.glpx.pro/turash/turash-frontend:latest \ context: bugulma/frontend
--destination=registry.bk.glpx.pro/turash/turash-frontend:${{ gitea.sha }} \ file: bugulma/frontend/Dockerfile
--cache=true \ push: true
--cache-ttl=168h \ tags: |
--compressed-caching=false 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
backend-lint: backend-lint:
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -108,22 +111,25 @@ jobs:
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 - uses: actions/checkout@v4
- name: Build and push backend with Kaniko - name: Set up Docker Buildx
run: | uses: docker/setup-buildx-action@v3
mkdir -p /tmp/kaniko-docker - name: Log in to registry
echo "{\"auths\":{\"registry.bk.glpx.pro\":{\"username\":\"${{ secrets.DOCKER_USERNAME }}\",\"password\":\"${{ secrets.DOCKER_PASSWORD }}\"}}}" > /tmp/kaniko-docker/config.json uses: docker/login-action@v3
docker run --rm \ with:
-v $(pwd):/workspace \ registry: registry.bk.glpx.pro
-v /tmp/kaniko-docker:/kaniko/.docker \ username: ${{ secrets.DOCKER_USERNAME }}
-e DOCKER_CONFIG=/kaniko/.docker \ password: ${{ secrets.DOCKER_PASSWORD }}
gcr.io/kaniko-project/executor:v1.24.0 \ - name: Build and push backend
--dockerfile=/workspace/bugulma/backend/Dockerfile \ uses: docker/build-push-action@v5
--context=/workspace/bugulma/backend \ with:
--destination=registry.bk.glpx.pro/turash/turash-backend:latest \ context: bugulma/backend
--destination=registry.bk.glpx.pro/turash/turash-backend:${{ gitea.sha }} \ file: bugulma/backend/Dockerfile
--cache=true \ push: true
--cache-ttl=168h \ tags: |
--compressed-caching=false 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
e2e-test: e2e-test:
runs-on: ubuntu-latest runs-on: ubuntu-latest