Skip to content

Commit

Permalink
test cache usage in dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
irdgss committed Nov 29, 2023
1 parent 3fdb782 commit f0073db
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 17 deletions.
15 changes: 2 additions & 13 deletions .github/workflows/build-courier-push-tag-shared.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,6 @@ jobs:
username: ${{ secrets.AWS_ACCESS_KEY_ID_SHARED }}
password: ${{ secrets.AWS_SECRET_ACCESS_KEY_SHARED }}

- name: Go Build Cache for Docker
uses: actions/cache@v3
with:
path: go-build-cache
key: ${{ runner.os }}-go-build-cache-${{ hashFiles('**/go.sum') }}

- name: inject go-build-cache into docker
uses: reproducible-containers/[email protected]
with:
cache-source: go-build-cache

- name: Build and push - Courier Image
uses: docker/build-push-action@v3
with:
Expand All @@ -77,8 +66,7 @@ jobs:
file: docker/Dockerfile
push: true
tags: "${{env.IMAGE_TAG}}"
cache-from: type=gha
cache-to: type=gha,mode=max
no-cache: true

- name: Check out Kubernetes Manifests
uses: actions/checkout@master
Expand Down Expand Up @@ -142,3 +130,4 @@ jobs:
directory: ./kubernetes-manifests/
branch: main
message: "From Courier Build (Push Tag ${{ env.MANIFESTS_ENVIRONMENT }})"

6 changes: 2 additions & 4 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@ FROM golang:1.17.5-alpine3.14 AS builder

WORKDIR /app

RUN go env -w GOMODCACHE=/root/.cache/go-build

RUN apk add --no-cache --virtual build-deps curl gcc

COPY go.mod go.sum ./
RUN --mount=type=cache,target=/root/.cache/go-build go mod download
RUN --mount=type=cache,target=/go/pkg/mod/ go mod download

COPY . ./
RUN --mount=type=cache,target=/root/.cache/go-build go install -v ./cmd/...
RUN --mount=type=cache,target=/go/pkg/mod/ go install -v ./cmd/...

FROM alpine:3.18.4

Expand Down

0 comments on commit f0073db

Please sign in to comment.