-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #51 from CS3219-AY2425S1/deployment-workings
NGINX Configurations for API Gateway, Code Updates for BE and FE Deployment
- Loading branch information
Showing
27 changed files
with
362 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
runtime: nodejs16 | ||
env: standard | ||
handlers: | ||
- url: / | ||
static_files: dist/peer-prep-fe/browser/index.html | ||
upload: dist/peer-prep-fe/browser/index.html | ||
- url: / | ||
static_dir: dist/peer-prep-fe/browser |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
#!/bin/bash | ||
|
||
echo "------------------------------------------------------------------------------" | ||
echo "Building and deploying peer-prep-question..." | ||
docker build --platform linux/amd64 -t gcr.io/g01-peer-prep/peer-prep-question ./peer-prep-be | ||
docker tag gcr.io/g01-peer-prep/peer-prep-question:latest gcr.io/g01-peer-prep/peer-prep-question:latest | ||
docker push gcr.io/g01-peer-prep/peer-prep-question:latest | ||
gcloud run deploy peer-prep-question \ | ||
--image gcr.io/g01-peer-prep/peer-prep-question:latest \ | ||
--region asia-southeast1 \ | ||
--allow-unauthenticated \ | ||
--set-env-vars "DB_URL=mongodb+srv://peer-prep:[email protected]/?retryWrites=true&w=majority&appName=peer-prep-cluster0" | ||
echo "peer-prep-question deployed successfully." | ||
echo "------------------------------------------------------------------------------" | ||
|
||
echo "------------------------------------------------------------------------------" | ||
echo "Building and deploying peer-prep-user..." | ||
docker build --platform linux/amd64 -t gcr.io/g01-peer-prep/peer-prep-user ./peer-prep-user/user-service | ||
docker tag gcr.io/g01-peer-prep/peer-prep-user:latest gcr.io/g01-peer-prep/peer-prep-user:latest | ||
docker push gcr.io/g01-peer-prep/peer-prep-user:latest | ||
gcloud run deploy peer-prep-user \ | ||
--image gcr.io/g01-peer-prep/peer-prep-user:latest \ | ||
--region asia-southeast1 \ | ||
--allow-unauthenticated \ | ||
--set-env-vars "ENV=PROD,DB_CLOUD_URI=mongodb+srv://peer-prep:[email protected]/?retryWrites=true&w=majority&appName=peer-prep-cluster0,JWT_SECRET=you-can-replace-this-with-your-own-secret" | ||
echo "peer-prep-user deployed successfully." | ||
echo "------------------------------------------------------------------------------" | ||
|
||
echo "------------------------------------------------------------------------------" | ||
echo "Building and deploying peer-prep-matching..." | ||
docker build --platform linux/amd64 -t gcr.io/g01-peer-prep/rabbitmq ./message_queue | ||
docker tag gcr.io/g01-peer-prep/rabbitmq:latest gcr.io/g01-peer-prep/rabbitmq:latest | ||
docker push gcr.io/g01-peer-prep/rabbitmq:latest | ||
gcloud run deploy peer-prep-matching \ | ||
--image gcr.io/g01-peer-prep/peer-prep-matching:latest \ | ||
--region asia-southeast1 \ | ||
--allow-unauthenticated \ | ||
--set-env-vars "AMQP_SERVER=amqps://lguugvwb:[email protected]/lguugvwb,MONGODB_URI=mongodb+srv://peer-prep:[email protected]/?retryWrites=true&w=majority&appName=peer-prep-cluster0" | ||
echo "peer-prep-matching deployed successfully." | ||
echo "------------------------------------------------------------------------------" | ||
|
||
echo "------------------------------------------------------------------------------" | ||
echo "Building and deploying peer-prep-collab..." | ||
docker build --platform linux/amd64 -t gcr.io/g01-peer-prep/peer-prep-collab ./peer-prep-collab | ||
docker tag gcr.io/g01-peer-prep/peer-prep-collab:latest gcr.io/g01-peer-prep/peer-prep-collab:latest | ||
docker push gcr.io/g01-peer-prep/peer-prep-collab:latest | ||
gcloud run deploy peer-prep-collab \ | ||
--image gcr.io/g01-peer-prep/peer-prep-collab:latest \ | ||
--region asia-southeast1 \ | ||
--allow-unauthenticated \ | ||
--set-env-vars "AMQP_SERVER=amqps://lguugvwb:[email protected]/lguugvwb,MATCHING_SERVICE_URL=https://peer-prep-matching-1093398872288.asia-southeast1.run.app,QUESTIONS_SERVICE_URL=https://peer-prep-question-1093398872288.asia-southeast1.run.app" | ||
echo "peer-prep-collab deployed successfully." | ||
echo "------------------------------------------------------------------------------" | ||
|
||
echo "------------------------------------------------------------------------------" | ||
echo "Building and deploying collab-websocket..." | ||
docker build --platform linux/amd64 -t gcr.io/g01-peer-prep/collab-websocket ./code-websocket | ||
docker tag gcr.io/g01-peer-prep/collab-websocket:latest gcr.io/g01-peer-prep/collab-websocket:latest | ||
docker push gcr.io/g01-peer-prep/collab-websocket:latest | ||
gcloud run deploy collab-websocket \ | ||
--image gcr.io/g01-peer-prep/collab-websocket:latest \ | ||
--region asia-southeast1 \ | ||
--allow-unauthenticated | ||
echo "collab-websocket deployed successfully." | ||
echo "------------------------------------------------------------------------------" | ||
|
||
echo "------------------------------------------------------------------------------" | ||
echo "Building and dploying peer-prep-gateway" | ||
docker build --platform linux/amd64 -t gcr.io/g01-peer-prep/peer-prep-gateway -f ./peer-prep-gateway/Dockerfile . | ||
docker tag gcr.io/g01-peer-prep/peer-prep-gateway:latest gcr.io/g01-peer-prep/peer-prep-gateway:latest | ||
docker push gcr.io/g01-peer-prep/peer-prep-gateway:latest | ||
gcloud run deploy peer-prep-gateway \ | ||
--image gcr.io/g01-peer-prep/peer-prep-gateway:latest \ | ||
--region asia-southeast1 \ | ||
--allow-unauthenticated | ||
echo "peer-prep-gateway deployed successfully." | ||
echo "------------------------------------------------------------------------------" | ||
|
||
echo "All microservices have been deployed, check for errors." | ||
|
||
# Easy access to the deployed services: | ||
# Question Service: https://peer-prep-question-1093398872288.asia-southeast1.run.app | ||
# User Service: https://peer-prep-user-1093398872288.asia-southeast1.run.app | ||
# Matching Service: https://peer-prep-matching-1093398872288.asia-southeast1.run.app | ||
# Collaboration Service: https://peer-prep-collab-1093398872288.asia-southeast1.run.app | ||
# WebSocket Service: https://collab-websocket-1093398872288.asia-southeast1.run.app | ||
# Gateway Service: https://peer-prep-gateway-1093398872288.asia-southeast1.run.app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
events { | ||
worker_connections 1024; | ||
} | ||
|
||
http { | ||
log_format main '$remote_addr - $remote_user [$time_local] "$request" ' | ||
'$status $body_bytes_sent "$http_referer" ' | ||
'"$http_user_agent" "$http_x_forwarded_for"'; | ||
|
||
access_log /var/log/nginx/access.log main; | ||
error_log /var/log/nginx/error.log warn; | ||
|
||
upstream question_service { | ||
server peer-prep-question-1093398872288.asia-southeast1.run.app; | ||
} | ||
|
||
upstream user_service { | ||
server peer-prep-user-1093398872288.asia-southeast1.run.app; | ||
} | ||
|
||
upstream matching_service { | ||
server peer-prep-matching-1093398872288.asia-southeast1.run.app; | ||
} | ||
|
||
upstream collab_service { | ||
server peer-prep-collab-1093398872288.asia-southeast1.run.app; | ||
} | ||
|
||
upstream websocket_service { | ||
server collab-websocket-1093398872288.asia-southeast1.run.app; | ||
} | ||
|
||
server { | ||
listen 8080; | ||
|
||
location /api/questions { | ||
proxy_pass https://peer-prep-question-1093398872288.asia-southeast1.run.app/questions; | ||
proxy_set_header X-Real-IP $remote_addr; | ||
proxy_set_header Host peer-prep-question-1093398872288.asia-southeast1.run.app; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_set_header X-Forwarded-Proto $scheme; | ||
} | ||
|
||
location /api/questions/ { | ||
proxy_pass https://peer-prep-question-1093398872288.asia-southeast1.run.app/questions/; | ||
proxy_set_header Host peer-prep-question-1093398872288.asia-southeast1.run.app; | ||
proxy_set_header X-Real-IP $remote_addr; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_set_header X-Forwarded-Proto $scheme; | ||
} | ||
|
||
location /api/categories { | ||
proxy_pass https://peer-prep-question-1093398872288.asia-southeast1.run.app/categories; | ||
proxy_set_header Host peer-prep-question-1093398872288.asia-southeast1.run.app; | ||
proxy_set_header X-Real-IP $remote_addr; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_set_header X-Forwarded-Proto $scheme; | ||
} | ||
|
||
location /api/categories/ { | ||
proxy_pass https://peer-prep-question-1093398872288.asia-southeast1.run.app/categories/; | ||
proxy_set_header Host peer-prep-question-1093398872288.asia-southeast1.run.app; | ||
proxy_set_header X-Real-IP $remote_addr; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_set_header X-Forwarded-Proto $scheme; | ||
} | ||
|
||
location /api/auth { | ||
proxy_pass https://peer-prep-user-1093398872288.asia-southeast1.run.app/auth; | ||
proxy_set_header Host peer-prep-user-1093398872288.asia-southeast1.run.app; | ||
proxy_set_header X-Real-IP $remote_addr; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_set_header X-Forwarded-Proto $scheme; | ||
} | ||
|
||
location /api/auth/ { | ||
proxy_pass https://peer-prep-user-1093398872288.asia-southeast1.run.app/auth/; | ||
proxy_set_header Host peer-prep-user-1093398872288.asia-southeast1.run.app; | ||
proxy_set_header X-Real-IP $remote_addr; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_set_header X-Forwarded-Proto $scheme; | ||
} | ||
|
||
location /api/users { | ||
proxy_pass https://peer-prep-user-1093398872288.asia-southeast1.run.app/users; | ||
proxy_set_header Host peer-prep-user-1093398872288.asia-southeast1.run.app; | ||
proxy_set_header X-Real-IP $remote_addr; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_set_header X-Forwarded-Proto $scheme; | ||
} | ||
|
||
location /api/users/ { | ||
proxy_pass https://peer-prep-user-1093398872288.asia-southeast1.run.app/users/; | ||
proxy_set_header Host peer-prep-user-1093398872288.asia-southeast1.run.app; | ||
proxy_set_header X-Real-IP $remote_addr; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_set_header X-Forwarded-Proto $scheme; | ||
} | ||
|
||
location /api/match { | ||
proxy_pass https://peer-prep-matching-1093398872288.asia-southeast1.run.app/match; | ||
proxy_set_header Host peer-prep-matching-1093398872288.asia-southeast1.run.app; | ||
proxy_set_header X-Real-IP $remote_addr; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_set_header X-Forwarded-Proto $scheme; | ||
} | ||
|
||
location /api/collab { | ||
proxy_pass https://peer-prep-collab-1093398872288.asia-southeast1.run.app/collab; | ||
proxy_set_header Host peer-prep-collab-1093398872288.asia-southeast1.run.app; | ||
proxy_set_header X-Real-IP $remote_addr; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_set_header X-Forwarded-Proto $scheme; | ||
} | ||
|
||
location /websocket/ { | ||
proxy_pass https://collab-websocket-1093398872288.asia-southeast1.run.app/; | ||
proxy_set_header Host collab-websocket-1093398872288.asia-southeast1.run.app; | ||
proxy_set_header X-Real-IP $remote_addr; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_set_header X-Forwarded-Proto $scheme; | ||
proxy_http_version 1.1; | ||
proxy_set_header Upgrade $http_upgrade; | ||
proxy_set_header Connection "upgrade"; | ||
add_header Access-Control-Allow-Origin https://g01-peer-prep.vercel.app; | ||
} | ||
|
||
error_page 404 /404.html; | ||
location = /404.html { | ||
internal; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ const ADD_SESSION_QUEUE = 'add_session_queue' | |
|
||
export const connectToRabbitMQ = async () => { | ||
try { | ||
const amqpServer = "amqps://lguugvwb:[email protected]/lguugvwb" | ||
const amqpServer = process.env.AMQP_SERVER || "amqps://lguugvwb:[email protected]/lguugvwb"; | ||
const connection = await amqp.connect(amqpServer) | ||
channel = await connection.createChannel() | ||
console.log("Connected to RabbitMQ") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,3 +49,4 @@ Thumbs.db | |
# Angular development server | ||
/.angular/ | ||
|
||
.vercel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
> Why do I have a folder named ".vercel" in my project? | ||
The ".vercel" folder is created when you link a directory to a Vercel project. | ||
|
||
> What does the "project.json" file contain? | ||
The "project.json" file contains: | ||
- The ID of the Vercel project that you linked ("projectId") | ||
- The ID of the user or team your Vercel project is owned by ("orgId") | ||
|
||
> Should I commit the ".vercel" folder? | ||
No, you should not share the ".vercel" folder with anyone. | ||
Upon creation, it will be automatically added to your ".gitignore" file. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"orgId":"team_GKhx06Xr5YsGKwEBsAosQhAU","projectId":"prj_22lBfKTHAtN1UMmfZdATwzmnDCtp"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const baseUrlProduction = "https://peer-prep-gateway-1093398872288.asia-southeast1.run.app/api"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.