Преглед изворни кода

Speedup docker builds by using cache

tags/v2.2.0^2^2
9seconds пре 1 месец
родитељ
комит
991346621c
2 измењених фајлова са 8 додато и 12 уклоњено
  1. 3
    11
      .github/workflows/ci.yaml
  2. 5
    1
      Dockerfile

+ 3
- 11
.github/workflows/ci.yaml Прегледај датотеку

123
       - name: Setup BuildX
123
       - name: Setup BuildX
124
         uses: docker/setup-buildx-action@v3
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
       - name: Login to DockerHub
126
       - name: Login to DockerHub
135
         if: github.event_name != 'pull_request'
127
         if: github.event_name != 'pull_request'
136
         uses: docker/login-action@v3
128
         uses: docker/login-action@v3
147
           password: ${{ secrets.GITHUB_TOKEN }}
139
           password: ${{ secrets.GITHUB_TOKEN }}
148
 
140
 
149
       - name: Build and push
141
       - name: Build and push
150
-        uses: docker/build-push-action@v2
142
+        uses: docker/build-push-action@v6
151
         with:
143
         with:
152
           pull: true
144
           pull: true
153
           context: .
145
           context: .
155
           push: ${{ github.event_name != 'pull_request' }}
147
           push: ${{ github.event_name != 'pull_request' }}
156
           tags: ${{ steps.meta.outputs.tags }}
148
           tags: ${{ steps.meta.outputs.tags }}
157
           labels: ${{ steps.meta.outputs.labels }}
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 Прегледај датотеку

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

Loading…
Откажи
Сачувај