diff --git a/.github/workflows/collab-be-aws.yml b/.github/workflows/collab-be-aws.yml index 2309c680..d7052b3a 100644 --- a/.github/workflows/collab-be-aws.yml +++ b/.github/workflows/collab-be-aws.yml @@ -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 diff --git a/.github/workflows/comm-be-aws.yml b/.github/workflows/comm-be-aws.yml index 3fc23404..33fb0fdd 100644 --- a/.github/workflows/comm-be-aws.yml +++ b/.github/workflows/comm-be-aws.yml @@ -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 diff --git a/.github/workflows/fe-aws.yml b/.github/workflows/fe-aws.yml index 3ced4414..f562d006 100644 --- a/.github/workflows/fe-aws.yml +++ b/.github/workflows/fe-aws.yml @@ -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 diff --git a/.github/workflows/matching-be-aws.yml b/.github/workflows/matching-be-aws.yml index 719fe96c..2b11a257 100644 --- a/.github/workflows/matching-be-aws.yml +++ b/.github/workflows/matching-be-aws.yml @@ -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 diff --git a/.github/workflows/question-be-aws.yml b/.github/workflows/question-be-aws.yml index cd22da4c..d59d0b16 100644 --- a/.github/workflows/question-be-aws.yml +++ b/.github/workflows/question-be-aws.yml @@ -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 diff --git a/.github/workflows/user-be-aws.yml b/.github/workflows/user-be-aws.yml index 3b0ecc7a..eb92b4a4 100644 --- a/.github/workflows/user-be-aws.yml +++ b/.github/workflows/user-be-aws.yml @@ -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 diff --git a/backend/collab-backend/Dockerfile b/backend/collab-backend/Dockerfile index 89291a0d..b110682f 100644 --- a/backend/collab-backend/Dockerfile +++ b/backend/collab-backend/Dockerfile @@ -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" ] \ No newline at end of file diff --git a/backend/collab-backend/Dockerfile.prod b/backend/collab-backend/Dockerfile.prod new file mode 100644 index 00000000..89291a0d --- /dev/null +++ b/backend/collab-backend/Dockerfile.prod @@ -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" ] \ No newline at end of file diff --git a/backend/collab-backend/index.js b/backend/collab-backend/index.js index 546b5146..2f0cdef2 100644 --- a/backend/collab-backend/index.js +++ b/backend/collab-backend/index.js @@ -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), diff --git a/backend/communication-backend/Dockerfile.prod b/backend/communication-backend/Dockerfile.prod new file mode 100644 index 00000000..dbeda8d1 --- /dev/null +++ b/backend/communication-backend/Dockerfile.prod @@ -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" ] \ No newline at end of file diff --git a/backend/matching_backend/Dockerfile b/backend/matching_backend/Dockerfile index c2dc046d..6e704fd7 100644 --- a/backend/matching_backend/Dockerfile +++ b/backend/matching_backend/Dockerfile @@ -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"] diff --git a/backend/matching_backend/Dockerfile.prod b/backend/matching_backend/Dockerfile.prod new file mode 100644 index 00000000..31e5a293 --- /dev/null +++ b/backend/matching_backend/Dockerfile.prod @@ -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"] diff --git a/backend/question-backend/Dockerfile b/backend/question-backend/Dockerfile index 863827c0..8646d57f 100644 --- a/backend/question-backend/Dockerfile +++ b/backend/question-backend/Dockerfile @@ -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"] diff --git a/backend/question-backend/Dockerfile.prod b/backend/question-backend/Dockerfile.prod new file mode 100644 index 00000000..863827c0 --- /dev/null +++ b/backend/question-backend/Dockerfile.prod @@ -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"] diff --git a/backend/user_profile_backend/Dockerfile b/backend/user_profile_backend/Dockerfile index 99e1304d..e65ebef9 100644 --- a/backend/user_profile_backend/Dockerfile +++ b/backend/user_profile_backend/Dockerfile @@ -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"] \ No newline at end of file diff --git a/backend/user_profile_backend/Dockerfile.prod b/backend/user_profile_backend/Dockerfile.prod new file mode 100644 index 00000000..a23fee30 --- /dev/null +++ b/backend/user_profile_backend/Dockerfile.prod @@ -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"] \ No newline at end of file diff --git a/frontend/Dockerfile.prod b/frontend/Dockerfile.prod new file mode 100644 index 00000000..78f31e42 --- /dev/null +++ b/frontend/Dockerfile.prod @@ -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"] \ No newline at end of file diff --git a/frontend/src/App.js b/frontend/src/App.js index e53e3f3a..75d24718 100644 --- a/frontend/src/App.js +++ b/frontend/src/App.js @@ -42,7 +42,7 @@ const App = () => { } /> } /> }> - }/> + {isLogin ? }/> : null} {isLogin ? } /> : null} {isLogin ? } /> : null} {isLogin ? } /> : null}