-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile.dev
35 lines (27 loc) · 872 Bytes
/
Dockerfile.dev
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
34
35
# syntax=docker/dockerfile:1-experimental
FROM --platform=${BUILDPLATFORM} golang:1.17.6-alpine AS base
WORKDIR /workspace
ENV CGO_ENABLED=0
# Copy the Go Modules manifests
COPY go.* .
# 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
FROM base AS builder
ARG TARGETOS
ARG TARGETARCH
# Copy the go source
COPY main.go main.go
COPY apis/ apis/
COPY config/ config/
COPY controllers/ controllers/
COPY pkg/ pkg/
# Build
ENV GO111MODULE=on
RUN --mount=type=cache,target=/root/.cache/go-build \
GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -a -o manager main.go
# Refer to https://github.com/GoogleContainerTools/distroless for more details
FROM ubuntu:20.04
WORKDIR /
COPY --from=builder /workspace/manager .
ENTRYPOINT ["/manager"]