-
Notifications
You must be signed in to change notification settings - Fork 2
/
Dockerfile
33 lines (28 loc) · 1.32 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# syntax=docker/dockerfile:1
# Build the manager binary
FROM --platform=$BUILDPLATFORM golang:1 as builder
WORKDIR /workspace
# Copy the Go Modules manifests
COPY piraeus-operator/go.mod go.mod
COPY piraeus-operator/go.sum go.sum
# cache deps before building and copying source so that we don't need to re-download as much
# and so that source changes don't invalidate our downloaded layer
RUN go mod download
# Copy the go source
COPY piraeus-operator/cmd/ cmd/
COPY piraeus-operator/api/ api/
COPY piraeus-operator/internal/ internal/
COPY piraeus-operator/pkg/ pkg/
COPY override/pkg/vars/branding.go pkg/vars/branding.go
# Build
ARG TARGETARCH
ARG TARGETOS
ARG GOPROXY
ARG VERSION=0.0.0
RUN --mount=type=cache,target=/root/.cache/go-build CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -a -ldflags "-X github.com/piraeusdatastore/piraeus-operator/v2/pkg/vars.Version=$VERSION" -o manager ./cmd
RUN --mount=type=cache,target=/root/.cache/go-build CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -a -ldflags "-X github.com/piraeusdatastore/piraeus-operator/v2/pkg/vars.Version=$VERSION" -o gencert ./cmd/gencert
# Use minimal base image to package the manager binary
FROM registry.access.redhat.com/ubi9/ubi-micro:latest
COPY --from=builder /workspace/manager /workspace/gencert /
USER 65534:65534
ENTRYPOINT ["/manager"]