Skip to content

Commit 81dc5dc

Browse files
committed
Merge branch 'main' into profile-and-hostory-pages
2 parents d08088e + ccd3d92 commit 81dc5dc

File tree

83 files changed

+8929
-262
lines changed

Some content is hidden

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

83 files changed

+8929
-262
lines changed

.env.sample

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ COLLAB_DB_LOCAL_URI=mongodb://collaboration-db:27017/collaboration-service
2424
YJS_DB_CLOUD_URI=mongodb+srv://<username>:<password>@cluster0.h5ukw.mongodb.net/yjs-documents?retryWrites=true&w=majority&appName=Cluster0
2525
YJS_DB_LOCAL_URI=mongodb://collaboration-db:27017/yjs-documents
2626

27+
# History Service
28+
HISTORY_DB_CLOUD_URI=<FILL-THIS-IN>
29+
HISTORY_DB_LOCAL_URI=mongodb://history-db:27017/history
30+
2731
# Will use cloud MongoDB Atlas database
2832
ENV=PROD
2933

.github/workflows/backend.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Deploy Backend Services
2+
3+
on:
4+
push:
5+
branches: [ 'production' ]
6+
7+
workflow_dispatch:
8+
9+
permissions:
10+
id-token: write # This is required for requesting the JWT
11+
contents: read # This is required for actions/checkout
12+
13+
env:
14+
AWS_REGION: ap-southeast-1
15+
ECS_CLUSTER: backend-cluster
16+
17+
jobs:
18+
deploy:
19+
name: Deploy Backend Service
20+
runs-on: ubuntu-latest
21+
environment: production
22+
23+
strategy:
24+
matrix:
25+
service: [ 'question', 'user', 'match', 'collaboration' ]
26+
27+
steps:
28+
- name: Checkout
29+
uses: actions/checkout@v4
30+
31+
- name: Configure AWS credentials
32+
id: aws-configure
33+
uses: aws-actions/[email protected]
34+
with:
35+
role-to-assume: ${{ secrets.AWS_BACKEND_ROLE }}
36+
role-session-name: GitHub_to_AWS_via_FederatedOIDC
37+
aws-region: ${{ env.AWS_REGION }}
38+
39+
- name: Login to AWS ECR
40+
id: login-ecr
41+
uses: aws-actions/[email protected]
42+
43+
- name: Build and push ${{ matrix.service }} image to AWS ECR
44+
id: build-image
45+
env:
46+
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
47+
ECR_REPOSITORY: ${{ matrix.service }}
48+
IMAGE_TAG: latest
49+
run: |
50+
echo "Building $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"
51+
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG ./services/${{ matrix.service }}
52+
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
53+
54+
- name: Update AWS Service (${{ matrix.service }}) # Trigger re-deployment with latest image
55+
id: update-service
56+
env:
57+
ECS_SERVICE: ${{ matrix.service }}-service
58+
run: |
59+
echo "Updating $ECS_SERVICE for $ECS_CLUSTER"
60+
aws ecs update-service \
61+
--cluster $ECS_CLUSTER \
62+
--service $ECS_SERVICE \
63+
--force-new-deployment \
64+
--region $AWS_REGION

.github/workflows/frontend.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Deploy Frontend
2+
3+
on:
4+
push:
5+
branches: [ 'production' ]
6+
7+
workflow_dispatch:
8+
9+
permissions:
10+
id-token: write # This is required for requesting the JWT
11+
contents: read # This is required for actions/checkout
12+
13+
env:
14+
AWS_REGION: ap-southeast-1
15+
S3_BUCKET_NAME: app.peerprep.org
16+
17+
jobs:
18+
deploy:
19+
name: Deploy Frontend
20+
runs-on: ubuntu-latest
21+
environment: production
22+
23+
steps:
24+
- uses: actions/checkout@v4
25+
26+
- name: Configure AWS credentials
27+
id: aws-configure
28+
uses: aws-actions/[email protected]
29+
with:
30+
role-to-assume: ${{ secrets.AWS_FRONTEND_ROLE }}
31+
role-session-name: GitHub_to_AWS_via_FederatedOIDC
32+
aws-region: ${{ env.AWS_REGION }}
33+
34+
- name: Build frontend distribution
35+
working-directory: frontend
36+
run: npm ci && npm run build
37+
38+
- name: Sync distribution to S3
39+
run: |
40+
aws s3 sync ./frontend/dist/frontend/browser/ s3://$S3_BUCKET_NAME --delete
41+
42+
- name: Invalidate Cloudfront Cache
43+
run: |
44+
aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_CLOUDFRONT_ID }} --paths "/*"

.github/workflows/tests.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,22 @@ jobs:
3636
run: cd ${{ matrix.service }} && npm run lint
3737
- name: Build App
3838
run: cd ${{ matrix.service }} && npm run build
39+
40+
41+
build-history:
42+
runs-on: ubuntu-latest
43+
timeout-minutes: 60
44+
steps:
45+
- uses: actions/checkout@v4
46+
- name: Use Node.js
47+
uses: actions/setup-node@v4
48+
with:
49+
node-version: ${{ env.node-version }}
50+
- name: Install Node Modules
51+
run: cd services/history && npm ci
52+
- name: Linting
53+
run: cd services/history && npm run lint
54+
- name: Build App
55+
run: cd services/history && npm run build
56+
- name: Run tests
57+
run: cd services/history && npm run test

compose.dev.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,26 @@ services:
4747
volumes:
4848
- /app/node_modules
4949
- ./services/collaboration:/app
50+
51+
collaboration-db:
52+
ports:
53+
- 27020:27017
54+
55+
collaboration-db:
56+
ports:
57+
- 27020:27017
58+
59+
history:
60+
command: npm run dev
61+
ports:
62+
- 8086:8086
63+
volumes:
64+
- /app/node_modules
65+
- ./services/history:/app
66+
67+
history-db:
68+
ports:
69+
- 27021:27017
5070

5171
broker:
5272
ports:

compose.yml

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ services:
2121
- user
2222
- match
2323
- collaboration
24+
- history
2425
networks:
2526
- gateway-network
2627
restart: always
@@ -167,12 +168,39 @@ services:
167168
networks:
168169
- collaboration-db-network
169170
restart: always
171+
172+
history:
173+
container_name: history
174+
image: history
175+
build:
176+
context: services/history
177+
dockerfile: Dockerfile
178+
environment:
179+
DB_CLOUD_URI: ${HISTORY_DB_CLOUD_URI}
180+
DB_LOCAL_URI: ${HISTORY_DB_LOCAL_URI}
181+
BROKER_URL: ${BROKER_URL}
182+
JWT_SECRET: ${JWT_SECRET}
183+
depends_on:
184+
broker:
185+
condition: service_healthy
186+
networks:
187+
- gateway-network
188+
- history-db-network
189+
190+
history-db:
191+
container_name: history-db
192+
image: mongo:7.0.14
193+
volumes:
194+
- history-db:/data/db
195+
networks:
196+
- history-db-network
170197

171198
volumes:
172199
question-db:
173200
user-db:
174201
match-db:
175202
collaboration-db:
203+
history-db:
176204

177205
networks:
178206
gateway-network:
@@ -184,4 +212,6 @@ networks:
184212
match-db-network:
185213
driver: bridge
186214
collaboration-db-network:
187-
driver: bridge
215+
driver: bridge
216+
history-db-network:
217+
driver: bridge

frontend/angular.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@
3737
"budgets": [
3838
{
3939
"type": "initial",
40-
"maximumWarning": "2MB",
41-
"maximumError": "3MB"
40+
"maximumWarning": "7MB",
41+
"maximumError": "10MB"
4242
},
4343
{
4444
"type": "anyComponentStyle",

0 commit comments

Comments
 (0)