Skip to content

Commit

Permalink
Make ready for production
Browse files Browse the repository at this point in the history
  • Loading branch information
zzthian committed Nov 4, 2023
1 parent 7040ccf commit 3bf1f22
Show file tree
Hide file tree
Showing 18 changed files with 72 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/collab-be-aws.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
# push it to ECR so that it can
# be deployed to ECS.
docker build -t $ECR_REGISTRY/$ECR_COLLABORATION_REPOSITORY:$IMAGE_TAG -f ./backend/collab-backend/Dockerfile ./backend/collab-backend
docker build -t $ECR_REGISTRY/$ECR_COLLABORATION_REPOSITORY:$IMAGE_TAG -f ./backend/collab-backend/Dockerfile.prod ./backend/collab-backend
docker push $ECR_REGISTRY/$ECR_COLLABORATION_REPOSITORY:$IMAGE_TAG
echo "image=$ECR_REGISTRY/$ECR_COLLABORATION_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/comm-be-aws.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
# push it to ECR so that it can
# be deployed to ECS.
docker build -t $ECR_REGISTRY/$ECR_COMMUNICATION_REPOSITORY:$IMAGE_TAG -f ./backend/communication-backend/Dockerfile ./backend/communication-backend
docker build -t $ECR_REGISTRY/$ECR_COMMUNICATION_REPOSITORY:$IMAGE_TAG -f ./backend/communication-backend/Dockerfile.prod ./backend/communication-backend
docker push $ECR_REGISTRY/$ECR_COMMUNICATION_REPOSITORY:$IMAGE_TAG
echo "image=$ECR_REGISTRY/$ECR_COMMUNICATION_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/fe-aws.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ jobs:
# push it to ECR so that it can
# be deployed to ECS.
docker build -t $ECR_REGISTRY/$ECR_FRONTEND_REPOSITORY:$IMAGE_TAG -f ./frontend/Dockerfile ./frontend
docker build -t $ECR_REGISTRY/$ECR_FRONTEND_REPOSITORY:$IMAGE_TAG -f ./frontend/Dockerfile.prod ./frontend
docker push $ECR_REGISTRY/$ECR_FRONTEND_REPOSITORY:$IMAGE_TAG
echo "image=$ECR_REGISTRY/$ECR_FRONTEND_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/matching-be-aws.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
# push it to ECR so that it can
# be deployed to ECS.
docker build -t $ECR_REGISTRY/$ECR_MATCHING_REPOSITORY:$IMAGE_TAG -f ./backend/matching_backend/Dockerfile ./backend/matching_backend
docker build -t $ECR_REGISTRY/$ECR_MATCHING_REPOSITORY:$IMAGE_TAG -f ./backend/matching_backend/Dockerfile.prod ./backend/matching_backend
docker push $ECR_REGISTRY/$ECR_MATCHING_REPOSITORY:$IMAGE_TAG
echo "image=$ECR_REGISTRY/$ECR_MATCHING_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/question-be-aws.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
# push it to ECR so that it can
# be deployed to ECS.
docker build -t $ECR_REGISTRY/$ECR_QUESTION_REPOSITORY:$IMAGE_TAG -f ./backend/question-backend/Dockerfile ./backend/question-backend
docker build -t $ECR_REGISTRY/$ECR_QUESTION_REPOSITORY:$IMAGE_TAG -f ./backend/question-backend/Dockerfile.prod ./backend/question-backend
docker push $ECR_REGISTRY/$ECR_QUESTION_REPOSITORY:$IMAGE_TAG
echo "image=$ECR_REGISTRY/$ECR_QUESTION_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/user-be-aws.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
# push it to ECR so that it can
# be deployed to ECS.
docker build -t $ECR_REGISTRY/$ECR_USER_REPOSITORY:$IMAGE_TAG -f ./backend/user_profile_backend/Dockerfile ./backend/user_profile_backend
docker build -t $ECR_REGISTRY/$ECR_USER_REPOSITORY:$IMAGE_TAG -f ./backend/user_profile_backend/Dockerfile.prod ./backend/user_profile_backend
docker push $ECR_REGISTRY/$ECR_USER_REPOSITORY:$IMAGE_TAG
echo "image=$ECR_REGISTRY/$ECR_USER_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT
Expand Down
2 changes: 1 addition & 1 deletion backend/collab-backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install
COPY . .
# ENV FRONTEND_HOST=https://peerprep.jonoans.com

EXPOSE 9000
CMD [ "node", "index.js" ]
8 changes: 8 additions & 0 deletions backend/collab-backend/Dockerfile.prod
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM node:18
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install
COPY . .
# ENV FRONTEND_HOST=https://peerprep.jonoans.com
EXPOSE 9000
CMD [ "node", "index.js" ]
4 changes: 2 additions & 2 deletions backend/collab-backend/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,13 @@ async function findOrFetchNewQuestion(id, complexity) {
if (id == null) return;

const release = await question_mutex.acquire();
var question = null;
let question = null;
try {
question = await roomSchema.findById(id);

// if document is null, aka isn't in the DB
if (!question) {
quesiton = await fetchQuestionByComplexity(complexity)
question = await fetchQuestionByComplexity(complexity)
question = await roomSchema.create({
_id: id,
question: await fetchQuestionByComplexity(complexity),
Expand Down
8 changes: 8 additions & 0 deletions backend/communication-backend/Dockerfile.prod
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM node:18
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install
COPY . .
ENV FRONTEND_HOST=https://peerprep.jonoans.com
EXPOSE 9001
CMD [ "node", "index.js" ]
4 changes: 1 addition & 3 deletions backend/matching_backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ WORKDIR /src/app
COPY package*.json ./
RUN npm install
COPY . .
# ENV USER_HOST=http://peerprep-g53-fe-2022344057.ap-southeast-1.elb.amazonaws.com/api/users
# ENV FRONTEND_HOST=https://peerprep.jonoans.com
# ENV COLLAB_HOST=http://peerprep-g53-fe-2022344057.ap-southeast-1.elb.amazonaws.com

EXPOSE 3001
CMD ["npm", "start"]
10 changes: 10 additions & 0 deletions backend/matching_backend/Dockerfile.prod
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM node:18
WORKDIR /src/app
COPY package*.json ./
RUN npm install
COPY . .
ENV USER_HOST=http://peerprep-g53-fe-2022344057.ap-southeast-1.elb.amazonaws.com/api/users
ENV FRONTEND_HOST=https://peerprep.jonoans.com
ENV COLLAB_HOST=http://peerprep-g53-fe-2022344057.ap-southeast-1.elb.amazonaws.com
EXPOSE 3001
CMD ["npm", "start"]
2 changes: 1 addition & 1 deletion backend/question-backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ WORKDIR /src/app
COPY package*.json ./
RUN npm install
COPY . .
# ENV USER_HOST=http://peerprep-g53-fe-2022344057.ap-southeast-1.elb.amazonaws.com/api/users

EXPOSE 8000
CMD ["node", "index.js"]
8 changes: 8 additions & 0 deletions backend/question-backend/Dockerfile.prod
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM node:18
WORKDIR /src/app
COPY package*.json ./
RUN npm install
COPY . .
# ENV USER_HOST=http://peerprep-g53-fe-2022344057.ap-southeast-1.elb.amazonaws.com/api/users
EXPOSE 8000
CMD ["node", "index.js"]
2 changes: 1 addition & 1 deletion backend/user_profile_backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ WORKDIR /src/app
COPY package*.json ./
RUN npm install
COPY . .
# ENV USER_HOST=http://peerprep-g53-fe-2022344057.ap-southeast-1.elb.amazonaws.com/api/users

EXPOSE 4000
CMD ["node", "index.js"]
8 changes: 8 additions & 0 deletions backend/user_profile_backend/Dockerfile.prod
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM node:18
WORKDIR /src/app
COPY package*.json ./
RUN npm install
COPY . .
ENV USER_HOST=http://peerprep-g53-fe-2022344057.ap-southeast-1.elb.amazonaws.com/api/users
EXPOSE 4000
CMD ["node", "index.js"]
17 changes: 17 additions & 0 deletions frontend/Dockerfile.prod
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM node:18
WORKDIR /src/app
COPY package*.json ./
RUN npm install
COPY . .

ENV REACT_APP_USER_HOST=https://peerprep.jonoans.com/api/users
ENV REACT_APP_QUESTION_HOST=https://peerprep.jonoans.com/api/questions
ENV REACT_APP_MATCHING_HOST=https://peerprep.jonoans.com:8443
ENV REACT_APP_COLLAB_HOST=https://peerprep.jonoans.com
ENV REACT_APP_COMMUNICATION_HOST=https://peerprep.jonoans.com:2096
ENV REACT_APP_CATEGORIES_HOST=https://peerprep.jonoans.com/api/categories

RUN npm run build
RUN npm i -g serve
EXPOSE 3000
CMD ["serve", "-s", "build"]
2 changes: 1 addition & 1 deletion frontend/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const App = () => {
<Route path="signup" element={<SignupPage />} />
<Route path="logout" element={<Logout />} />
<Route path="/" element={<Layout />}>
<Route path="match" element = {<Match/>}/>
{isLogin ? <Route path="match" element = {<Match/>}/> : null}
{isLogin ? <Route path="questionpage" element={<QuestionPage />} /> : null}
{isLogin ? <Route path="profile" element={<UserProfile />} /> : null}
{isLogin ? <Route path="room/:id" element={<Room />} /> : null}
Expand Down

0 comments on commit 3bf1f22

Please sign in to comment.