Skip to content

Commit c2e6571

Browse files
authored
Merge branch 'master' into master
2 parents 61e7540 + 87e4747 commit c2e6571

File tree

96 files changed

+4885
-4188
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+4885
-4188
lines changed

.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ POSTGRES_DB="user-service"
66
PG_PORT=5432
77
SECRET_KEY=
88

9+
REDIS_PASSWORD=
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
name: Selectively Build and Push to Artifact Registry
2+
3+
on:
4+
push:
5+
branches: ["master"]
6+
7+
env:
8+
PROJECT_ID: cs3219-400714
9+
REGION: asia-southeast1
10+
GAR_LOCATION: asia-southeast1-docker.pkg.dev/cs3219-400714/peerprep/
11+
12+
jobs:
13+
build-push-artifact:
14+
runs-on: ubuntu-latest
15+
outputs:
16+
build_status: ${{ steps.set_output.outputs.build_status }}
17+
steps:
18+
- name: "Checkout"
19+
uses: "actions/checkout@v3"
20+
21+
- name: Detect Changes in Microservices
22+
id: changes
23+
uses: dorny/paths-filter@v2
24+
with:
25+
filters: |
26+
frontend:
27+
- 'frontend/**'
28+
user_service:
29+
- 'user_service/**'
30+
question_service:
31+
- 'question_service/**'
32+
matching_service:
33+
- 'matching_service/**'
34+
collab_service:
35+
- 'collab_service/**'
36+
37+
- name: 'Create env file'
38+
run: |
39+
echo "${{ secrets.ENV_FILE }}" > .env
40+
41+
- name: "Set up google auth"
42+
id: auth
43+
uses: "google-github-actions/auth@v1"
44+
with:
45+
credentials_json: "${{ secrets.SERVICE_ACCOUNT_KEY }}"
46+
47+
- name: "Set up Cloud SDK"
48+
uses: "google-github-actions/setup-gcloud@v1"
49+
50+
- name: "Use gcloud CLI"
51+
run: "gcloud info"
52+
53+
- name: "Docker auth"
54+
run: |-
55+
gcloud auth configure-docker ${{ env.REGION }}-docker.pkg.dev --quiet
56+
57+
- name: Determine Build Status
58+
id: set_output
59+
run: echo "::set-output name=build_status::false"
60+
61+
- name: 1. Build and Push frontend
62+
if: steps.changes.outputs.frontend == 'true'
63+
run: |
64+
docker-compose build frontend
65+
docker-compose push frontend
66+
echo "::set-output name=build_status::true"
67+
68+
- name: 2. Build and Push question-service
69+
if: steps.changes.outputs.question_service == 'true'
70+
run: |
71+
docker-compose build question-service
72+
docker-compose push question-service
73+
echo "::set-output name=build_status::true"
74+
75+
- name: 3. Build and Push user-service
76+
if: steps.changes.outputs.user_service == 'true'
77+
run: |
78+
docker-compose build user-service
79+
docker-compose push user-service
80+
echo "::set-output name=build_status::true"
81+
82+
- name: 4. Build and Push matching-service
83+
if: steps.changes.outputs.matching_service == 'true'
84+
run: |
85+
docker-compose build matching-service
86+
docker-compose push matching-service
87+
echo "::set-output name=build_status::true"
88+
89+
- name: 5. Build and Push collab-service
90+
if: steps.changes.outputs.collab_service == 'true'
91+
run: |
92+
docker-compose build collab-service
93+
docker-compose push collab-service
94+
echo "::set-output name=build_status::true"
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Build and Push to Artifact Registry
2+
3+
on:
4+
workflow_dispatch
5+
6+
env:
7+
PROJECT_ID: cs3219-400714
8+
REGION: asia-southeast1
9+
GAR_LOCATION: asia-southeast1-docker.pkg.dev/cs3219-400714/peerprep/
10+
11+
jobs:
12+
build-push-artifact:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: "Checkout"
16+
uses: "actions/checkout@v3"
17+
18+
- name: 'Create env file'
19+
run: |
20+
echo "${{ secrets.ENV_FILE }}" > .env
21+
22+
- id: "auth"
23+
uses: "google-github-actions/auth@v1"
24+
with:
25+
credentials_json: "${{ secrets.SERVICE_ACCOUNT_KEY }}"
26+
27+
- name: "Set up Cloud SDK"
28+
uses: "google-github-actions/setup-gcloud@v1"
29+
30+
- name: "Use gcloud CLI"
31+
run: "gcloud info"
32+
33+
- name: "Docker auth"
34+
run: |-
35+
gcloud auth configure-docker ${{ env.REGION }}-docker.pkg.dev --quiet
36+
37+
- name: Build image
38+
run: docker-compose build
39+
40+
- name: Push image
41+
run: docker-compose push

.github/workflows/deployment.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Deployment Workflow
2+
3+
on:
4+
workflow_dispatch:
5+
workflow_run:
6+
workflows: ["Selectively Build and Push to Artifact Registry", "Build and Push to Artifact Registry"]
7+
types:
8+
- completed
9+
10+
jobs:
11+
deploy:
12+
runs-on: ubuntu-latest
13+
if: >
14+
github.event_name == 'workflow_dispatch' ||
15+
(github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.outputs.build_status == 'true')
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v2
19+
20+
- name: "Set up google auth"
21+
id: auth
22+
uses: "google-github-actions/auth@v1"
23+
with:
24+
credentials_json: "${{ secrets.SERVICE_ACCOUNT_KEY }}"
25+
26+
- name: "Use gcloud CLI"
27+
run: "gcloud info"
28+
29+
- name: "SSH to VM"
30+
id: 'compute-ssh'
31+
uses: 'google-github-actions/ssh-compute@v0'
32+
with:
33+
instance_name: 'peerprep-prod'
34+
zone: 'asia-southeast1-b'
35+
ssh_private_key: '${{ secrets.SSH_KEY }}'
36+
command: 'echo "${{ secrets.ENV_FILE }}" | sudo tee /usr/src/peerprep/.env > /dev/null && sudo chmod 777 /usr/src/peerprep/scripts/init.sh && sudo /usr/src/peerprep/scripts/init.sh'
37+
38+
- id: 'test'
39+
run: |-
40+
echo '${{ steps.compute-ssh.outputs.stdout }}'
41+
echo '${{ steps.compute-ssh.outputs.stderr }}'

.gitignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
/coverage
1010

1111
# production
12-
/build
12+
*/build
13+
*/dist
1314

1415
# misc
1516
.DS_Store
@@ -21,5 +22,4 @@
2122

2223
npm-debug.log*
2324
yarn-debug.log*
24-
yarn-error.log*
25-
frontend/package-lock.json
25+
yarn-error.log*

README.md

Lines changed: 7 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,13 @@
1-
# Frontend
1+
# Running this project
22

3-
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
3+
Simply run `docker-compose up --build` or `docker compose up --build`
44

5-
## Available Scripts
65

7-
In the project directory, you can run:
6+
# For devs
87

9-
### `npm start`
8+
TBA
109

11-
Runs the app in the development mode.\
12-
Open [http://localhost:3000](http://localhost:3000) to view it in your browser.
10+
To manually push to our service registry, please set up gcloud authentication with our project title
11+
Then build the images as you would normally with `docker-compose build`
12+
Then push the builds to the registry with `docker-compose push`
1313

14-
The page will reload when you make changes.\
15-
You may also see any lint errors in the console.
16-
17-
### `npm test`
18-
19-
Launches the test runner in the interactive watch mode.\
20-
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
21-
22-
### `npm run build`
23-
24-
Builds the app for production to the `build` folder.\
25-
It correctly bundles React in production mode and optimizes the build for the best performance.
26-
27-
The build is minified and the filenames include the hashes.\
28-
Your app is ready to be deployed!
29-
30-
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
31-
32-
### `npm run eject`
33-
34-
**Note: this is a one-way operation. Once you `eject`, you can't go back!**
35-
36-
If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
37-
38-
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own.
39-
40-
You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it.
41-
42-
43-
# Backend
44-
45-
## Question Service
46-
47-
The question service depends on a MongoDB instance to serve as the database.
48-
To start the question service on localhost, run `docker-compose -f .\docker_compose_dev.yml up` at the root of this project.
49-
50-
The server should be accessible via the endpoint
51-
`localhost:8080/api/questions/`
52-
53-
See the comments `question_service/questionController.js` for the list of endpoints
File renamed without changes.

code_execution/Dockerfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FROM node:18-alpine
2+
WORKDIR /usr/src/app
3+
COPY package*.json ./
4+
RUN npm install
5+
# RUN npm ci --omit=dev
6+
COPY . .
7+
EXPOSE 8090
8+
CMD ["npm", "run", "start"]

code_execution/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Quickstart
2+
3+
1. Start the server on Local Host
4+
- Run `npm start`
5+
2. Run the test.js file
6+
3. Navigate to debug console for output

0 commit comments

Comments
 (0)