From 1de9cd36e10e11c753319edff13fb094261e2a3b Mon Sep 17 00:00:00 2001 From: kurt Date: Fri, 11 Oct 2024 20:08:37 +0800 Subject: [PATCH 1/2] update nextjs env --- .github/workflows/deploy.yml | 3 +++ cloudbuild.yaml | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 9402b13024..5eba5cbc74 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -31,6 +31,9 @@ jobs: env: NEXT_PUBLIC_QUESTION_SERVICE_URL: ${{ secrets.NEXT_PUBLIC_QUESTION_SERVICE_URL }} NEXT_PUBLIC_AUTH_SERVICE_URL: ${{ secrets.NEXT_PUBLIC_AUTH_SERVICE_URL }} + NEXT_PUBLIC_USER_SERVICE_URL: ${{ secrets.NEXT_PUBLIC_USER_SERVICE_URL }} + USER_SERVICE_URL: ${{ secrets.USER_SERVICE_URL }} + QUESTION_SERVICE_URL: ${{ secrets.QUESTION_SERVICE_URL }} run: | gcloud builds submit --config cloudbuild.yaml \ --substitutions _NEXT_PUBLIC_QUESTION_SERVICE_URL=$NEXT_PUBLIC_QUESTION_SERVICE_URL,_NEXT_PUBLIC_AUTH_SERVICE_URL=$NEXT_PUBLIC_AUTH_SERVICE_URL diff --git a/cloudbuild.yaml b/cloudbuild.yaml index d702f06cf5..4d4432fb32 100644 --- a/cloudbuild.yaml +++ b/cloudbuild.yaml @@ -12,6 +12,12 @@ steps: "NEXT_PUBLIC_QUESTION_SERVICE_URL=${_NEXT_PUBLIC_QUESTION_SERVICE_URL}", "--build-arg", "NEXT_PUBLIC_AUTH_SERVICE_URL=${_NEXT_PUBLIC_AUTH_SERVICE_URL}", + "--build-arg", + "NEXT_PUBLIC_USER_SERVICE_URL=${_NEXT_PUBLIC_USER_SERVICE_URL}", + "--build-arg", + "USER_SERVICE_URL=${_USER_SERVICE_URL}", + "--build-arg", + "QUESTION_SERVICE_URL=${_QUESTION_SERVICE_URL}", "-f", "peerprep-fe/Dockerfile", "peerprep-fe", From 4c6bb4fd6e59fb9ff56534be2764bc651f550fbe Mon Sep 17 00:00:00 2001 From: kurt Date: Fri, 11 Oct 2024 20:22:14 +0800 Subject: [PATCH 2/2] update env pointers --- .github/workflows/deploy.yml | 3 +-- cloudbuild.yaml | 4 +--- k8s/peerprep-config.yml | 2 ++ peerprep-fe/Dockerfile | 4 ++++ peerprep-fe/next.config.mjs | 2 ++ peerprep-fe/src/middleware.ts | 2 +- peerprep-fe/src/network/axiosClient.ts | 2 +- peerprep-fe/src/network/axiosServer.ts | 2 +- 8 files changed, 13 insertions(+), 8 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 5eba5cbc74..96e8c018b6 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -31,8 +31,7 @@ jobs: env: NEXT_PUBLIC_QUESTION_SERVICE_URL: ${{ secrets.NEXT_PUBLIC_QUESTION_SERVICE_URL }} NEXT_PUBLIC_AUTH_SERVICE_URL: ${{ secrets.NEXT_PUBLIC_AUTH_SERVICE_URL }} - NEXT_PUBLIC_USER_SERVICE_URL: ${{ secrets.NEXT_PUBLIC_USER_SERVICE_URL }} - USER_SERVICE_URL: ${{ secrets.USER_SERVICE_URL }} + AUTH_SERVICE_URL: ${{ secrets.AUTH_SERVICE_URL }} QUESTION_SERVICE_URL: ${{ secrets.QUESTION_SERVICE_URL }} run: | gcloud builds submit --config cloudbuild.yaml \ diff --git a/cloudbuild.yaml b/cloudbuild.yaml index 4d4432fb32..7fc2e31c50 100644 --- a/cloudbuild.yaml +++ b/cloudbuild.yaml @@ -13,9 +13,7 @@ steps: "--build-arg", "NEXT_PUBLIC_AUTH_SERVICE_URL=${_NEXT_PUBLIC_AUTH_SERVICE_URL}", "--build-arg", - "NEXT_PUBLIC_USER_SERVICE_URL=${_NEXT_PUBLIC_USER_SERVICE_URL}", - "--build-arg", - "USER_SERVICE_URL=${_USER_SERVICE_URL}", + "AUTH_SERVICE_URL=${_AUTH_SERVICE_URL}", "--build-arg", "QUESTION_SERVICE_URL=${_QUESTION_SERVICE_URL}", "-f", diff --git a/k8s/peerprep-config.yml b/k8s/peerprep-config.yml index 98f4c8c428..ae1f6620c8 100644 --- a/k8s/peerprep-config.yml +++ b/k8s/peerprep-config.yml @@ -6,3 +6,5 @@ type: Opaque stringData: NEXT_PUBLIC_QUESTION_SERVICE_URL: "${_NEXT_PUBLIC_QUESTION_SERVICE_URL}" NEXT_PUBLIC_AUTH_SERVICE_URL: "${_NEXT_PUBLIC_AUTH_SERVICE_URL}" + AUTH_SERVICE_URL: "${_AUTH_SERVICE_URL}" + QUESTION_SERVICE_URL: "${_QUESTION_SERVICE_URL}" diff --git a/peerprep-fe/Dockerfile b/peerprep-fe/Dockerfile index 1f6ffd5808..f5d8efa1d6 100644 --- a/peerprep-fe/Dockerfile +++ b/peerprep-fe/Dockerfile @@ -33,10 +33,14 @@ ENV PORT=3000 # Accept build arguments ARG NEXT_PUBLIC_QUESTION_SERVICE_URL ARG NEXT_PUBLIC_AUTH_SERVICE_URL +ARG AUTH_SERVICE_URL +ARG QUESTION_SERVICE_URL # Set environment variables ENV NEXT_PUBLIC_QUESTION_SERVICE_URL=$NEXT_PUBLIC_QUESTION_SERVICE_URL ENV NEXT_PUBLIC_AUTH_SERVICE_URL=$NEXT_PUBLIC_AUTH_SERVICE_URL +ENV AUTH_SERVICE_URL=$AUTH_SERVICE_URL +ENV QUESTION_SERVICE_URL=$QUESTION_SERVICE_URL COPY . . RUN pnpm build diff --git a/peerprep-fe/next.config.mjs b/peerprep-fe/next.config.mjs index 06532b679d..48655a5cda 100644 --- a/peerprep-fe/next.config.mjs +++ b/peerprep-fe/next.config.mjs @@ -5,6 +5,8 @@ const nextConfig = { NEXT_PUBLIC_QUESTION_SERVICE_URL: process.env.NEXT_PUBLIC_QUESTION_SERVICE_URL, NEXT_PUBLIC_AUTH_SERVICE_URL: process.env.NEXT_PUBLIC_AUTH_SERVICE_URL, + AUTH_SERVICE_URL: process.env.AUTH_SERVICE_URL, + QUESTION_SERVICE_URL: process.env.QUESTION_SERVICE_URL, }, }; diff --git a/peerprep-fe/src/middleware.ts b/peerprep-fe/src/middleware.ts index 2c9d53fba3..82ebcd0884 100644 --- a/peerprep-fe/src/middleware.ts +++ b/peerprep-fe/src/middleware.ts @@ -1,7 +1,7 @@ import { NextResponse } from 'next/server'; import type { NextRequest } from 'next/server'; -const baseURL = process.env.USER_SERVICE_URL || 'http://172.17.0.1:3001/api/v1'; +const baseURL = process.env.AUTH_SERVICE_URL || 'http://172.17.0.1:3001/api/v1'; // This function can be marked `async` if using `await` inside export async function middleware(request: NextRequest) { diff --git a/peerprep-fe/src/network/axiosClient.ts b/peerprep-fe/src/network/axiosClient.ts index 086ff35a72..ae4f2f6ac1 100644 --- a/peerprep-fe/src/network/axiosClient.ts +++ b/peerprep-fe/src/network/axiosClient.ts @@ -12,7 +12,7 @@ const axiosQuestionClient = axios.create({ const axiosAuthClient = axios.create({ baseURL: - process.env.NEXT_PUBLIC_USER_SERVICE_URL || 'http://localhost:3001/api/v1', + process.env.NEXT_PUBLIC_AUTH_SERVICE_URL || 'http://localhost:3001/api/v1', headers: { 'Content-Type': 'application/json', }, diff --git a/peerprep-fe/src/network/axiosServer.ts b/peerprep-fe/src/network/axiosServer.ts index f33b504538..483e87f7d9 100644 --- a/peerprep-fe/src/network/axiosServer.ts +++ b/peerprep-fe/src/network/axiosServer.ts @@ -10,7 +10,7 @@ const axiosQuestionServer = axios.create({ }); const axiosAuthServer = axios.create({ - baseURL: process.env.USER_SERVICE_URL || 'http://172.17.0.1:3001/api/v1', + baseURL: process.env.AUTH_SERVICE_URL || 'http://172.17.0.1:3001/api/v1', headers: { 'Content-Type': 'application/json', },