This repository has been archived by the owner on Jul 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
27 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,23 @@ | ||
FROM golang:1.15 as builder | ||
# set GOPATH to empty since we're building with modules. | ||
ENV GOPATH= | ||
WORKDIR /workspace/ | ||
COPY go.mod go.mod | ||
COPY go.sum go.sum | ||
RUN go mod download | ||
COPY . . | ||
ARG BUILD_INFO=unspecified | ||
RUN \ | ||
CGO_ENABLED=0 \ | ||
GOOS=linux \ | ||
go build -ldflags="-w -X 'main.BuildInfo=${BUILD_INFO}'" -o workflow-manager ./ | ||
|
||
FROM scratch | ||
COPY ca-certificates.crt /etc/ssl/certs/ca-certificates.crt | ||
COPY workflow-manager workflow-manager | ||
ARG BUILD_INFO=unspecified | ||
LABEL build_info="${BUILD_INFO}" | ||
# The container needs a copy of trusted roots. Copy them from the builder image. | ||
# See | ||
# https://medium.com/@kelseyhightower/optimizing-docker-images-for-static-binaries-b5696e26eb07 | ||
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt | ||
COPY --from=builder /workspace/workflow-manager workflow-manager | ||
ENTRYPOINT ["/workflow-manager"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,10 @@ | ||
#!/bin/bash -eux | ||
# The container needs a copy of trusted roots. Try to copy them from the OS. | ||
# See | ||
# https://medium.com/@kelseyhightower/optimizing-docker-images-for-static-binaries-b5696e26eb07 | ||
# and | ||
# https://github.com/golang/go/blob/master/src/crypto/x509/root_linux.go#L7 | ||
cd $(dirname $0) | ||
|
||
# Embed info about the build. | ||
COMMIT_ID="$(git rev-parse --short=8 HEAD)" | ||
BUILD_ID="$(git symbolic-ref --short HEAD 2>/dev/null || true)+${COMMIT_ID}" | ||
BUILD_TIME="$(date -u)" | ||
GO_BUILD_FLAGS="-ldflags=-w -X 'main.BuildID=${BUILD_ID}' -X 'main.BuildTime=${BUILD_TIME}'" | ||
BUILD_TIME="$(date)" | ||
BUILD_INFO="${BUILD_ID} - ${BUILD_TIME}" | ||
|
||
cp /etc/ssl/certs/ca-certificates.crt . \ | ||
|| cp /etc/pki/tls/certs/ca-bundle.crt ca-certificates.crt \ | ||
|| cp /etc/pki/tls/certs/ca-bundle.crt ca-certificates.crt | ||
CGO_ENABLED=0 GOOS=linux go build "$GO_BUILD_FLAGS" -o workflow-manager main.go | ||
docker build --tag letsencrypt/prio-workflow-manager . | ||
rm ca-certificates.crt | ||
docker build --tag letsencrypt/prio-workflow-manager --build-arg BUILD_INFO="${BUILD_INFO}" . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters