diff --git a/Dockerfile b/Dockerfile index 445366c4f..b5801f0e3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM node:20-alpine3.20 AS base +FROM node:20.16.0-alpine3.20 AS base WORKDIR /base COPY package*.json ./ RUN npm ci && npm cache clean --force @@ -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,9 +28,21 @@ 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 - -FROM node:20-alpine3.20 AS production +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.16.0-alpine3.20 AS production ENV NODE_ENV=production ARG user=nodeuser @@ -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} diff --git a/components/Layout.js b/components/Layout.js index c31dbef64..884528104 100644 --- a/components/Layout.js +++ b/components/Layout.js @@ -10,6 +10,7 @@ import { useRouter } from 'next/router' import throttle from 'lodash.throttle' import IdleTimeout from './IdleTimeout' import { signOut } from 'next-auth/react' +import getConfig from 'next/config' export default function Layout(props) { const t = props.locale === 'en' ? en : fr @@ -144,48 +145,31 @@ export default function Layout(props) {
{props.children}
- - - {process.env.ENVIRONMENT === 'production' ? ( -