From 7cc84c6f76219395efb6061939338c38c5717243 Mon Sep 17 00:00:00 2001 From: lhr-git <102617425+lhr-git@users.noreply.github.com> Date: Tue, 16 Jul 2024 16:27:18 -0400 Subject: [PATCH] Add Root Cert Structure to Dockerfile --- Dockerfile | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 445366c4f..7bdd516cf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,6 +9,8 @@ FROM base AS build # Build envs ARG HOSTALIAS_CERT ENV HOSTALIAS_CERT=$HOSTALIAS_CERT +ARG HOSTALIAS_ROOT_CERT +ENV HOSTALIAS_ROOT_CERT=$HOSTALIAS_ROOT_CERT ARG LOGGING_LEVEL=info ENV LOGGING_LEVEL=$LOGGING_LEVEL ARG AEM_GRAPHQL_ENDPOINT=https://www.canada.ca/graphql/execute.json/decd-endc/ @@ -26,7 +28,19 @@ ENV NODE_ENV=production WORKDIR /build COPY --from=base /base ./ -RUN mkdir -p /usr/local/share/ca-certificates/ && echo ${HOSTALIAS_CERT} | sed 's/\\n/\n/g' | xargs > /usr/local/share/ca-certificates/env.crt && chmod 644 /usr/local/share/ca-certificates/env.crt && npm run build +RUN mkdir -p /usr/local/share/ca-certificates/ && \ +echo ${HOSTALIAS_CERT} | \ +sed 's/\\n/\n/g' | \ +xargs > \ +/usr/local/share/ca-certificates/env.crt && \ +chmod 644 /usr/local/share/ca-certificates/env.crt && \ +mkdir -p /etc/ssl/certs/ && \ +echo ${HOSTALIAS_ROOT_CERT} | \ +sed 's/\\n/\n/g' | \ +xargs > \ +/etc/ssl/certs/root.crt && \ +chmod 644 /etc/ssl/certs/root.crt && \ +npm run build FROM node:20-alpine3.20 AS production ENV NODE_ENV=production @@ -51,9 +65,13 @@ RUN addgroup \ WORKDIR ${home} +COPY --from=build /etc/ssl/certs/root.crt /etc/ssl/certs/root.crt COPY --from=build --chown=${user}:${group} /usr/local/share/ca-certificates/env.crt ${MSCA_NG_CERT_LOCATION} -RUN apk update && apk add ca-certificates && rm -rf /var/cache/apk/* && update-ca-certificates +RUN apk update && \ +apk add ca-certificates && \ +rm -rf /var/cache/apk/* && \ +update-ca-certificates USER ${user}