Skip to content

Commit

Permalink
Merge pull request #56 from CS3219-AY2425S1/chore/update_env
Browse files Browse the repository at this point in the history
update nextjs env
  • Loading branch information
Kurtyjlee authored Oct 11, 2024
2 parents 6fc94ea + 4c6bb4f commit 677ef59
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ jobs:
env:
NEXT_PUBLIC_QUESTION_SERVICE_URL: ${{ secrets.NEXT_PUBLIC_QUESTION_SERVICE_URL }}
NEXT_PUBLIC_AUTH_SERVICE_URL: ${{ secrets.NEXT_PUBLIC_AUTH_SERVICE_URL }}
AUTH_SERVICE_URL: ${{ secrets.AUTH_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
4 changes: 4 additions & 0 deletions cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ 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",
"AUTH_SERVICE_URL=${_AUTH_SERVICE_URL}",
"--build-arg",
"QUESTION_SERVICE_URL=${_QUESTION_SERVICE_URL}",
"-f",
"peerprep-fe/Dockerfile",
"peerprep-fe",
Expand Down
2 changes: 2 additions & 0 deletions k8s/peerprep-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
4 changes: 4 additions & 0 deletions peerprep-fe/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions peerprep-fe/next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
};

Expand Down
2 changes: 1 addition & 1 deletion peerprep-fe/src/middleware.ts
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion peerprep-fe/src/network/axiosClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
},
Expand Down
2 changes: 1 addition & 1 deletion peerprep-fe/src/network/axiosServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
},
Expand Down

0 comments on commit 677ef59

Please sign in to comment.