Skip to content

Commit

Permalink
Fips changes for Static Linking
Browse files Browse the repository at this point in the history
  • Loading branch information
zulfilee authored and snehala27 committed Feb 14, 2024
1 parent 68f7b3c commit 123166e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
9 changes: 7 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,20 @@ FROM golang:1.21.4-alpine3.18 as dev
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

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
Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,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

Expand Down Expand Up @@ -84,7 +87,7 @@ 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)
Expand Down

0 comments on commit 123166e

Please sign in to comment.