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 843ef2c commit 3fdb782
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
15 changes: 13 additions & 2 deletions .github/workflows/build-courier-push-tag-shared.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,17 @@ 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 @@ -66,7 +77,8 @@ jobs:
file: docker/Dockerfile
push: true
tags: "${{env.IMAGE_TAG}}"
no-cache: true
cache-from: type=gha
cache-to: type=gha,mode=max

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

6 changes: 4 additions & 2 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ 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 go mod download
RUN --mount=type=cache,target=/root/.cache/go-build go mod download

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

FROM alpine:3.18.4

Expand Down

0 comments on commit 3fdb782

Please sign in to comment.