From f0c5bdf63669e9d759b31a89943d80fef6772c56 Mon Sep 17 00:00:00 2001 From: OxSaitama Date: Tue, 7 Nov 2023 15:07:46 +0100 Subject: [PATCH] set env var for build job --- .circleci/config.yml | 18 ++++++++++++++++++ Dockerfile | 6 +++--- next.config.js | 14 ++++++++++++++ src/pages/_app.tsx | 3 ++- 4 files changed, 37 insertions(+), 4 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 1dfd1d18..ed4ca625 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -52,6 +52,24 @@ workflows: build-and-register-stg: jobs: - build-push-docker-image: + environment: + TAG: << pipeline.git.tag >> + NEXT_PUBLIC_ADMIN_ID: jelkvelknvlkn + NEXT_PUBLIC_BACK_API_HOST: api.stg.lecoffre.smart-chain.fr + NEXT_PUBLIC_BACK_API_PROTOCOL: https:// + NEXT_PUBLIC_BACK_API_ROOT_URL: /api + NEXT_PUBLIC_BACK_API_VERSION: /v1 + NEXT_PUBLIC_FC_AUTHORIZE_ENDPOINT: https://fcp.integ01.dev-franceconnect.fr/api/v1/authorize + NEXT_PUBLIC_FC_CLIENT_ID: 211286433e39cce01db448d80181bdfd005554b19cd51b3fe7943f6b3b86ab6e + NEXT_PUBLIC_FRONT_APP_HOST: https://app.stg.lecoffre.smart-chain.fr + NEXT_PUBLIC_FRONT_APP_PORT: 3000 + NEXT_PUBLIC_IDNOT_BASE_URL: "https://qual-connexion.idnot.fr" + NEXT_PUBLIC_IDNOT_AUTHORIZE_ENDPOINT: "/IdPOAuth2/authorize/idnot_idp_v1" + NEXT_PUBLIC_IDNOT_CLIENT_ID: "4501646203F3EF67" + NEXT_PUBLIC_DOCAPOST_API_URL: "https://preprod.id360docaposte.com/api/1.0.0" + NEXT_PUBLIC_DOCAPOST_DOCUMENT_PROCESS_ID: 49508376-b160-475d-9224-9bb6511215b8 + NEXT_PUBLIC_DOCAPOST_CONNECT_PROCESS_ID: 54c14875-f864-4819-8cd4-4fc6dd4a947b + NEXT_PUBLIC_DOCAPOST_APP_ID: leCoffre@smart_chain context: - sc-shared-prd filters: diff --git a/Dockerfile b/Dockerfile index b8a0d2d3..4bdea185 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,7 +12,7 @@ RUN chmod 600 ~/.ssh/id_rsa RUN eval "$(ssh-agent -s)" && ssh-add /root/.ssh/id_rsa RUN ssh-keyscan github.com smart-chain-fr/leCoffre-resources.git >> /root/.ssh/known_hosts -RUN npm install --frozen-lockfile +# RUN npm install --frozen-lockfile # Rebuild the source code only when needed FROM node:19-alpine AS builder @@ -22,8 +22,8 @@ WORKDIR leCoffre-front COPY --from=deps leCoffre-front/node_modules ./node_modules COPY --from=deps leCoffre-front/package.json package.json COPY tsconfig.json tsconfig.json +COPY next.config.js next.config.js COPY src src -COPY .env .env RUN npm run build @@ -35,9 +35,9 @@ WORKDIR leCoffre-front RUN adduser -D lecoffreuser --uid 10000 && chown -R lecoffreuser . COPY public ./public -COPY --from=builder --chown=lecoffreuser leCoffre-front/.env ./.env COPY --from=builder --chown=lecoffreuser leCoffre-front/node_modules ./node_modules COPY --from=builder --chown=lecoffreuser leCoffre-front/.next ./.next +COPY --from=builder --chown=lecoffreuser leCoffre-front/next.config.js ./next.config.js COPY --from=builder --chown=lecoffreuser leCoffre-front/package.json ./package.json USER lecoffreuser diff --git a/next.config.js b/next.config.js index b2ceb073..997db3d9 100644 --- a/next.config.js +++ b/next.config.js @@ -28,6 +28,20 @@ const nextConfig = { NEXT_PUBLIC_IDNOT_BASE_URL: process.env.NEXT_PUBLIC_IDNOT_BASE_URL, NEXT_PUBLIC_DOCAPOSTE_API_URL: process.env.NEXT_PUBLIC_DOCAPOSTE_API_URL, }, + + env: { + NEXT_PUBLIC_BACK_API_PROTOCOL: process.env.NEXT_PUBLIC_BACK_API_PROTOCOL, + NEXT_PUBLIC_BACK_API_HOST: process.env.NEXT_PUBLIC_BACK_API_HOST, + NEXT_PUBLIC_BACK_API_ROOT_URL: process.env.NEXT_PUBLIC_BACK_API_ROOT_URL, + NEXT_PUBLIC_BACK_API_VERSION: process.env.NEXT_PUBLIC_BACK_API_VERSION, + NEXT_PUBLIC_FRONT_APP_HOST: process.env.NEXT_PUBLIC_FRONT_APP_HOST, + NEXT_PUBLIC_FRONT_APP_PORT: process.env.NEXT_PUBLIC_FRONT_APP_PORT, + NEXT_PUBLIC_IDNOT_AUTHORIZE_ENDPOINT: process.env.NEXT_PUBLIC_IDNOT_AUTHORIZE_ENDPOINT, + NEXT_PUBLIC_IDNOT_CLIENT_ID: process.env.NEXT_PUBLIC_IDNOT_CLIENT_ID, + NEXT_PUBLIC_IDNOT_BASE_URL: process.env.NEXT_PUBLIC_IDNOT_BASE_URL, + NEXT_PUBLIC_DOCAPOSTE_API_URL: process.env.NEXT_PUBLIC_DOCAPOSTE_API_URL, + }, + // webpack: config => { // config.node = { // fs: 'empty', diff --git a/src/pages/_app.tsx b/src/pages/_app.tsx index a2e09430..bce2c795 100644 --- a/src/pages/_app.tsx +++ b/src/pages/_app.tsx @@ -26,7 +26,7 @@ type AppPropsWithLayout = AppProps & { docaposteApiUrl: string; }; -const { publicRuntimeConfig, serverRuntimeConfig } = getConfig(); +const { publicRuntimeConfig, serverRuntimeConfig, env } = getConfig(); const MyApp = (({ Component, @@ -67,6 +67,7 @@ MyApp.getInitialProps = async () => { console.log("runtime config", publicRuntimeConfig); console.log("server runtime config", serverRuntimeConfig); console.log("process env", process.env['NEXT_PUBLIC_BACK_API_PROTOCOL'] || "env undefined"); + console.log("env config", env); return { backApiProtocol: publicRuntimeConfig.NEXT_PUBLIC_BACK_API_PROTOCOL, backApiHost: publicRuntimeConfig.NEXT_PUBLIC_BACK_API_HOST,