diff --git a/Dockerfile b/Dockerfile index 1a998d9c..5a6dd226 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,11 @@ # syntax=docker/dockerfile:experimental -FROM golang:1.19.8-alpine3.17 as dev +FROM golang:1.19.10-alpine3.18 as dev # FIPS ARG CRYPTO_LIB ENV GOEXPERIMENT=${CRYPTO_LIB:+boringcrypto} -RUN apk add --no-cache git ca-certificates make +RUN apk add --no-cache git ca-certificates make gcc g++ RUN adduser -D appuser COPY . /src/ WORKDIR /src @@ -13,7 +13,12 @@ WORKDIR /src ENV GO111MODULE=on RUN --mount=type=cache,sharing=locked,id=gomod,target=/go/pkg/mod/cache \ --mount=type=cache,sharing=locked,id=goroot,target=/root/.cache/go-build \ - CGO_ENABLED=0 GOOS=linux make build + if [ ${CRYPTO_LIB} ]; \ + then \ + CGO_ENABLED=1 FIPS_ENABLE=yes GOOS=linux make build ;\ + else \ + CGO_ENABLED=0 GOOS=linux make build ;\ + fi FROM scratch # Add Certificates into the image, for anything that does API calls diff --git a/Makefile b/Makefile index 6102e5bf..e209eac0 100644 --- a/Makefile +++ b/Makefile @@ -23,6 +23,9 @@ TARGETOS=linux # Use linker flags to provide version/build settings to the target LDFLAGS=-ldflags "-s -w -X=main.Version=$(VERSION) -X=main.Build=$(BUILD) -extldflags -static" +ifeq ($(FIPS_ENABLE),yes) + LDFLAGS=-ldflags "-s -w -X=main.Version=$(VERSION) -X=main.Build=$(BUILD) -linkmode=external -extldflags -static" +endif DOCKERTAG ?= $(VERSION) REPOSITORY = plndr @@ -83,7 +86,7 @@ release-dockerx86: docker: @-rm ./kube-vip - @docker buildx build --build-arg CRYPTO_LIB=${FIPS_ENABLE} --platform linux/amd64 --push -t ${IMG} . + @docker buildx build --build-arg CRYPTO_LIB=${FIPS_ENABLE} --push --platform linux/amd64 -t ${IMG} . @echo New Multi Architecture Docker image created ## Local (docker load of images)