generated from cybozu-go/neco-template
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Dockerfile
21 lines (15 loc) · 718 Bytes
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# stage1: build the binary
FROM --platform=$BUILDPLATFORM ghcr.io/cybozu/golang:1.21-jammy as builder
ARG TARGETARCH
COPY ./ .
RUN GOARCH=${TARGETARCH} CGO_ENABLED=0 go build -ldflags="-w -s" -a -o moco-agent ./cmd/moco-agent
RUN GOARCH=${TARGETARCH} CGO_ENABLED=0 go build -ldflags="-w -s" -a -o moco-init ./cmd/moco-init
RUN GOARCH=${TARGETARCH} CGO_ENABLED=0 go build -ldflags="-w -s" -a -o cp ./cmd/cp
# stage2: build the final image
FROM --platform=$TARGETPLATFORM scratch
LABEL org.opencontainers.image.source https://github.com/cybozu-go/moco-agent
COPY --from=builder /work/moco-agent /
COPY --from=builder /work/moco-init /
COPY --from=builder /work/cp /bin/
USER 10000:10000
ENTRYPOINT ["/moco-agent"]