Parcourir la source

Speedup docker builds by using cache

tags/v2.2.0^2^2
9seconds il y a 1 mois
Parent
révision
991346621c
2 fichiers modifiés avec 8 ajouts et 12 suppressions
  1. 3
    11
      .github/workflows/ci.yaml
  2. 5
    1
      Dockerfile

+ 3
- 11
.github/workflows/ci.yaml Voir le fichier

@@ -123,14 +123,6 @@ jobs:
123 123
       - name: Setup BuildX
124 124
         uses: docker/setup-buildx-action@v3
125 125
 
126
-      - name: Setup cache
127
-        uses: actions/cache@v5
128
-        with:
129
-          path: /tmp/buildx-cache
130
-          key: ${{ runner.os }}-buildx-${{ github.sha }}
131
-          restore-keys: |
132
-            ${{ runner.os }}-buildx-
133
-
134 126
       - name: Login to DockerHub
135 127
         if: github.event_name != 'pull_request'
136 128
         uses: docker/login-action@v3
@@ -147,7 +139,7 @@ jobs:
147 139
           password: ${{ secrets.GITHUB_TOKEN }}
148 140
 
149 141
       - name: Build and push
150
-        uses: docker/build-push-action@v2
142
+        uses: docker/build-push-action@v6
151 143
         with:
152 144
           pull: true
153 145
           context: .
@@ -155,5 +147,5 @@ jobs:
155 147
           push: ${{ github.event_name != 'pull_request' }}
156 148
           tags: ${{ steps.meta.outputs.tags }}
157 149
           labels: ${{ steps.meta.outputs.labels }}
158
-          cache-from: type=local,src=/tmp/buildx-cache
159
-          cache-to: type=local,dest=/tmp/buildx-cache
150
+          cache-from: type=gha
151
+          cache-to: type=gha,mode=max

+ 5
- 1
Dockerfile Voir le fichier

@@ -11,9 +11,13 @@ RUN set -x \
11 11
     ca-certificates \
12 12
     git
13 13
 
14
-COPY . /app
14
+COPY go.mod go.sum /app/
15 15
 WORKDIR /app
16 16
 
17
+RUN go mod download
18
+
19
+COPY . /app
20
+
17 21
 RUN set -x \
18 22
   && version="$(git describe --exact-match HEAD 2>/dev/null || git describe --tags --always)" \
19 23
   && go build \

Chargement…
Annuler
Enregistrer