forked from hashicorp/terraform-provider-google
-
Notifications
You must be signed in to change notification settings - Fork 1
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
1 parent
7d70dd6
commit d9cdaf8
Showing
2 changed files
with
70 additions
and
1 deletion.
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
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# syntax=docker/dockerfile:1 | ||
ARG GO_VERSION=1.21.3 | ||
|
||
############### | ||
# Build stage # | ||
############### | ||
FROM golang:${GO_VERSION}-bullseye as builder | ||
|
||
# Our base image is AMD64 only, so we need to compile for that. Because we use | ||
# CGO (for boringcrypto), we either need to cross-compile or run the builder in | ||
# an AMD64-emulated environment. That emulated environment gets slow (build | ||
# times >3mins), so we opted for cross-compilation instead. | ||
RUN apt update && apt install -y gcc-x86-64-linux-gnu | ||
|
||
ARG APP | ||
WORKDIR /go/src/${APP} | ||
|
||
# Add go module files | ||
COPY go.mod go.sum ./ | ||
|
||
# Download and cache dependencies in a dedicated layer. | ||
RUN go mod download | ||
|
||
# Add source code | ||
COPY . . | ||
|
||
# Build | ||
RUN --mount=type=cache,target=/root/.cache/go-build \ | ||
# use the C toolchain that the *target image* requires, and compile for \ | ||
# that arch. Our images are ubuntu-based, so GCC. \ | ||
CC=x86_64-linux-gnu-gcc \ | ||
GOARCH=amd64 \ | ||
# CGO is required for boringcrypto. \ | ||
CGO_ENABLED=1 \ | ||
# BoringCrypto is a FIPS-compliant Crypto library. \ | ||
GOEXPERIMENT=boringcrypto \ | ||
go build -v -o /go/bin/app . | ||
# ensure the binary uses BoringCrypto and not StandardCrypto. \ | ||
#go run rsc.io/goversion@master -crypto /go/bin/app | grep -q '(boring crypto) +crypto/tls/fipsonly' |