Skip to content

Commit ec9779d

Browse files
committed
[GPCAPIM-289]: Update Docker build process to include dev certificates
- Add INCLUDE_DEV_CERTS argument to control installation of dev certificates - Modify Dockerfile to handle dev certificates based on the new argument - Adjust Makefile to pass INCLUDE_DEV_CERTS during the build process
1 parent 21c9b90 commit ec9779d

File tree

2 files changed

+21
-10
lines changed

2 files changed

+21
-10
lines changed

Makefile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ endif
2020
IMAGE_NAME := ${IMAGE_REPOSITORY}:${IMAGE_TAG}
2121
COMMIT_VERSION := $(shell git rev-parse --short HEAD)
2222
BUILD_DATE := $(shell date -u +"%Y%m%d")
23+
INCLUDE_DEV_CERTS ?= ${DEV_CERTS_INCLUDED}
2324
# ==============================================================================
2425

2526
# Example CI/CD targets are: dependencies, build, publish, deploy, clean, etc.
@@ -54,7 +55,12 @@ build-gateway-api: dependencies
5455
.PHONY: build
5556
build: build-gateway-api # Build the project artefact @Pipeline
5657
@echo "Building Docker x86 image using Docker. Utilising python version: ${PYTHON_VERSION} ..."
57-
@$(docker) buildx build --platform linux/amd64 --load --provenance=false --build-arg PYTHON_VERSION=${PYTHON_VERSION} --build-arg COMMIT_VERSION=${COMMIT_VERSION} --build-arg BUILD_DATE=${BUILD_DATE} -t ${IMAGE_NAME} infrastructure/images/gateway-api
58+
@if [[ -n "$${IN_BUILD_CONTAINER}" ]]; then \
59+
echo "building with dev certs ..." ; \
60+
$(docker) buildx build --platform linux/amd64 --load --provenance=false --build-arg PYTHON_VERSION=${PYTHON_VERSION} --build-arg COMMIT_VERSION=${COMMIT_VERSION} --build-arg BUILD_DATE=${BUILD_DATE} --build-arg INCLUDE_DEV_CERTS=${INCLUDE_DEV_CERTS} -t ${IMAGE_NAME} infrastructure/images/gateway-api
61+
else \
62+
$(docker) buildx build --platform linux/amd64 --load --provenance=false --build-arg PYTHON_VERSION=${PYTHON_VERSION} --build-arg COMMIT_VERSION=${COMMIT_VERSION} --build-arg BUILD_DATE=${BUILD_DATE} -t ${IMAGE_NAME} infrastructure/images/gateway-api
63+
fi
5864
@echo "Docker image '${IMAGE_NAME}' built successfully!"
5965

6066
publish: # Publish the project artefact @Pipeline

infrastructure/images/gateway-api/Dockerfile

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,26 @@
22
ARG PYTHON_VERSION=invalid
33
FROM python:${PYTHON_VERSION}-alpine3.23 AS gateway-api
44

5-
RUN apk upgrade --no-cache && \
6-
pip install --no-cache-dir --upgrade pip && \
7-
addgroup -S nonroot && \
8-
adduser -S gateway_api_user -G nonroot
5+
# Controls whether dev certificates (if present) are installed into this image.
6+
ARG INCLUDE_DEV_CERTS=false
97

108
COPY resources/ /resources
119

1210
# If dev certificates have been copied into the build context, install them so
1311
# apk and other HTTPS clients inside this image trust the same CAs as the
1412
# dev container. This is a no-op when no dev certificates are provided.
15-
RUN if [ -d /resources/dev-certificates ]; then \
16-
cp -r /resources/dev-certificates/* /usr/local/share/ca-certificates/; \
17-
update-ca-certificates; \
18-
cp -r /resources/dev-certificates/* /etc/ssl/certs/; \
19-
fi
13+
RUN if [ "$INCLUDE_DEV_CERTS" = "true" ] && [ -d /resources/dev-certificates ]; then \
14+
cp -r /resources/dev-certificates/* /usr/local/share/ca-certificates/; \
15+
update-ca-certificates; \
16+
cp -r /resources/dev-certificates/* /etc/ssl/certs/; \
17+
else \
18+
rm -rf /resources/dev-certificates || true; \
19+
fi
20+
21+
RUN apk upgrade --no-cache && \
22+
pip install --no-cache-dir --upgrade pip && \
23+
addgroup -S nonroot && \
24+
adduser -S gateway_api_user -G nonroot
2025

2126
WORKDIR /resources/build/gateway-api
2227

0 commit comments

Comments
 (0)