Skip to content

Commit

Permalink
chore: improve container build layer caching (#414)
Browse files Browse the repository at this point in the history
Signed-off-by: Moritz Wiesinger <moritz.wiesinger@dynatrace.com>
  • Loading branch information
mowies authored Mar 23, 2023
1 parent ff199f1 commit 3212eba
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/pr-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ jobs:
context: .
outputs: type=docker,dest=${{ github.workspace }}/open-feature-operator-local.tar
tags: open-feature-operator-local:${{ github.sha }}
cache-from: type=gha,scope=${{ github.ref_name }}-ofo
cache-to: type=gha,scope=${{ github.ref_name }}-ofo
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ jobs:
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:main
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ needs.release-please.outputs.release_tag_name }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha,scope=${{ github.ref_name }}-ofo
cache-to: type=gha,scope=${{ github.ref_name }}-ofo


- name: Install cosign
Expand Down
7 changes: 4 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
FROM --platform=$BUILDPLATFORM golang:1.20.2-alpine3.16 AS builder

WORKDIR /workspace
ARG TARGETOS
ARG TARGETARCH
# Copy the Go Modules manifests
COPY go.mod go.mod
COPY go.sum go.sum
Expand All @@ -18,12 +16,15 @@ COPY webhooks/ webhooks/
COPY controllers/ controllers/
COPY pkg/ pkg/

ARG TARGETOS
ARG TARGETARCH

# Build
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -a -o manager main.go

# Use distroless as minimal base image to package the manager binary
# Refer to https://github.com/GoogleContainerTools/distroless for more details
FROM gcr.io/distroless/static:nonroot
FROM gcr.io/distroless/static:nonroot as production
WORKDIR /
COPY --from=builder /workspace/manager .
USER 65532:65532
Expand Down

0 comments on commit 3212eba

Please sign in to comment.