Speedup docker builds by using cache

This commit is contained in:
9seconds
2026-03-12 22:13:00 +01:00
parent a85348d6be
commit 991346621c
2 changed files with 8 additions and 12 deletions
+3 -11
View File
@@ -123,14 +123,6 @@ jobs:
- name: Setup BuildX - name: Setup BuildX
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
- name: Setup cache
uses: actions/cache@v5
with:
path: /tmp/buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Login to DockerHub - name: Login to DockerHub
if: github.event_name != 'pull_request' if: github.event_name != 'pull_request'
uses: docker/login-action@v3 uses: docker/login-action@v3
@@ -147,7 +139,7 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }} password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push - name: Build and push
uses: docker/build-push-action@v2 uses: docker/build-push-action@v6
with: with:
pull: true pull: true
context: . context: .
@@ -155,5 +147,5 @@ jobs:
push: ${{ github.event_name != 'pull_request' }} push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }} tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }} labels: ${{ steps.meta.outputs.labels }}
cache-from: type=local,src=/tmp/buildx-cache cache-from: type=gha
cache-to: type=local,dest=/tmp/buildx-cache cache-to: type=gha,mode=max
+5 -1
View File
@@ -11,9 +11,13 @@ RUN set -x \
ca-certificates \ ca-certificates \
git git
COPY . /app COPY go.mod go.sum /app/
WORKDIR /app WORKDIR /app
RUN go mod download
COPY . /app
RUN set -x \ RUN set -x \
&& version="$(git describe --exact-match HEAD 2>/dev/null || git describe --tags --always)" \ && version="$(git describe --exact-match HEAD 2>/dev/null || git describe --tags --always)" \
&& go build \ && go build \