Files
VDR/.gitea/workflows/build-docker-image.yml
Mohammad Mahdi 776c463c0c
All checks were successful
Build and Push Server Docker Image / build-server (push) Successful in 10m11s
GPT5 - Refactor build-docker-image workflow: streamline buildx setup, switch to inline build command, and improve cleanup process.
2025-09-03 19:46:11 +03:30

47 lines
1.6 KiB
YAML

name: Build and Push Server Docker Image
on:
push:
branches:
- master
jobs:
build-server:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx (ephemeral)
uses: docker/setup-buildx-action@v3
with:
install: true
driver-opts: network=host
buildkitd-flags: --debug
- name: Log in to registry
uses: docker/login-action@v2
with:
registry: ${{ secrets.REGISTRY_URL }}
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Set lowercase repo name
run: echo "REPO_NAME_LOWER=$(echo '${{ github.event.repository.name }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
- name: Build and push (no local cache)
run: |
docker buildx build \
--pull \
--no-cache \
--file VirtualDDNSRouter.Server/Dockerfile \
--tag ${{ secrets.REGISTRY_URL }}/${{ github.repository_owner }}/${{ env.REPO_NAME_LOWER }}:latest-server \
--cache-from type=registry,ref=${{ secrets.REGISTRY_URL }}/${{ github.repository_owner }}/${{ env.REPO_NAME_LOWER }}:buildcache \
--cache-to type=registry,ref=${{ secrets.REGISTRY_URL }}/${{ github.repository_owner }}/${{ env.REPO_NAME_LOWER }}:buildcache,mode=max \
--push \
VirtualDDNSRouter.Server
- name: Remove builder to delete all cache
run: |
BUILDER=$(docker buildx ls | awk '/\*/ {print $1}')
docker buildx rm "$BUILDER" || true