ARG BASE_IMAGE=localhost/monok8s/ctl-build-base:dev FROM --platform=$BUILDPLATFORM ${BASE_IMAGE} AS build ARG VERSION=dev ARG TARGETOS ARG TARGETARCH WORKDIR /src COPY . . RUN test -f pkg/buildinfo/buildinfo_gen.go RUN mkdir -p /out && \ GOOS=${TARGETOS} GOARCH=${TARGETARCH} CGO_ENABLED=0 \ go build -trimpath -ldflags="-s -w" \ -o /out/ctl ./cmd/ctl FROM alpine:latest AS cacerts FROM scratch ARG VERSION ARG TARGETOS ARG TARGETARCH ENV VERSION=${VERSION} WORKDIR / COPY --from=build /out/ctl /ctl COPY --from=cacerts /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ COPY out/uboot-tools/${TARGETOS}_${TARGETARCH}/fw_printenv /fw_printenv COPY out/uboot-tools/${TARGETOS}_${TARGETARCH}/fw_setenv /fw_setenv ENV PATH=/ ENTRYPOINT ["/ctl"] CMD ["agent"]