44
55variables :
66 BUILD_STABLE_REGISTRY : registry.ddbuild.io
7- DISTROLESS_ROOT_FIPS_BASE_IMAGE : registry.ddbuild.io/images/base/gbi-distroless-nossl-root-fips:release
87
98# Force git to remove any reference to the local disk copy of the repository
109before_script :
@@ -13,7 +12,8 @@ before_script:
1312stages :
1413 - build
1514
16- # Build and push the function image tagged with pipeline ID + commit SHA
15+ # Build and push the function image tagged with pipeline ID + commit SHA.
16+ # Runs automatically on every branch push.
1717build-image :
1818 stage : build
1919 rules :
@@ -33,28 +33,32 @@ build-image:
3333 echo "Building ${REGISTRY}/${IMAGE_NAME}:${IMAGE_TAG}"
3434
3535 cat > Dockerfile.ci << 'EOF'
36- FROM golang:1.25-alpine AS builder
37- WORKDIR /fn
38- ENV CGO_ENABLED=0
39- ENV GOFIPS140=v1.0.0
36+ FROM --platform=$TARGETPLATFORM registry.ddbuild.io/images/mirror/golang:1.25.6 AS builder
37+ LABEL target=prod
38+ ARG TARGETOS
39+ ARG TARGETARCH
40+ ARG TARGETPLATFORM
41+ WORKDIR /workspace
4042 COPY go.mod go.sum ./
4143 RUN go mod download
4244 COPY . .
43- RUN GOOS=linux go build -o /function .
44- FROM registry.ddbuild.io/images/base/gbi-distroless-nossl-root-fips:release
45- COPY --from=builder /function /function
46- EXPOSE 9443
47- USER 65532
48- ENTRYPOINT ["/function"]
45+ ENV CGO_ENABLED=1
46+ ENV GOEXPERIMENT=boringcrypto
47+ RUN go build -tags fips -o /workspace/function .
48+ FROM --platform=$TARGETPLATFORM registry.ddbuild.io/images/base/gbi-ubuntu_2404-fips:release
49+ LABEL target=prod
50+ LABEL is_fips=true
51+ WORKDIR /home/dog
52+ COPY --from=builder /workspace/function /home/dog/function
53+ COPY package/crossplane.yaml /package.yaml
54+ USER dog
55+ ENTRYPOINT ["/home/dog/function"]
4956 EOF
5057
5158 METADATA_FILE=$(mktemp)
5259 docker buildx build \
5360 --platform "${PLATFORMS}" \
5461 --file Dockerfile.ci \
55- --label is_fips=true \
56- --label version="${IMAGE_TAG}" \
57- --label target=prod \
5862 --label CI_PIPELINE_ID="${CI_PIPELINE_ID}" \
5963 --label CI_JOB_ID="${CI_JOB_ID}" \
6064 --tag "${REGISTRY}/${IMAGE_NAME}:${IMAGE_TAG}" \
@@ -95,28 +99,32 @@ build-release:
9599 echo "Building release ${REGISTRY}/${IMAGE_NAME}:${IMAGE_TAG}"
96100
97101 cat > Dockerfile.ci << 'EOF'
98- FROM golang:1.25-alpine AS builder
99- WORKDIR /fn
100- ENV CGO_ENABLED=0
101- ENV GOFIPS140=v1.0.0
102+ FROM --platform=$TARGETPLATFORM registry.ddbuild.io/images/mirror/golang:1.25.6 AS builder
103+ LABEL target=prod
104+ ARG TARGETOS
105+ ARG TARGETARCH
106+ ARG TARGETPLATFORM
107+ WORKDIR /workspace
102108 COPY go.mod go.sum ./
103109 RUN go mod download
104110 COPY . .
105- RUN GOOS=linux go build -o /function .
106- FROM registry.ddbuild.io/images/base/gbi-distroless-nossl-root-fips:release
107- COPY --from=builder /function /function
108- EXPOSE 9443
109- USER 65532
110- ENTRYPOINT ["/function"]
111+ ENV CGO_ENABLED=1
112+ ENV GOEXPERIMENT=boringcrypto
113+ RUN go build -tags fips -o /workspace/function .
114+ FROM --platform=$TARGETPLATFORM registry.ddbuild.io/images/base/gbi-ubuntu_2404-fips:release
115+ LABEL target=prod
116+ LABEL is_fips=true
117+ WORKDIR /home/dog
118+ COPY --from=builder /workspace/function /home/dog/function
119+ COPY package/crossplane.yaml /package.yaml
120+ USER dog
121+ ENTRYPOINT ["/home/dog/function"]
111122 EOF
112123
113124 METADATA_FILE=$(mktemp)
114125 docker buildx build \
115126 --platform "${PLATFORMS}" \
116127 --file Dockerfile.ci \
117- --label is_fips=true \
118- --label version="${IMAGE_TAG}" \
119- --label target=prod \
120128 --label CI_PIPELINE_ID="${CI_PIPELINE_ID}" \
121129 --label CI_JOB_ID="${CI_JOB_ID}" \
122130 --annotation target=staging \
0 commit comments