Skip to content

Commit beda92e

Browse files
committed
final submission
1 parent 70832f9 commit beda92e

File tree

13 files changed

+61
-26
lines changed

13 files changed

+61
-26
lines changed

.env.example

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ POSTGRES_DB="user-service"
66
PG_PORT=5432
77
SECRET_KEY=
88

9-
REDIS_PASSWORD=
9+
REDIS_PASSWORD=
10+
REACT_APP_BACKEND_HOST="localhost"

G10_Report.pdf

2.67 MB
Binary file not shown.

README.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
# Running this project
22

3-
Simply run `docker-compose up --build` or `docker compose up --build`
3+
Simply run `docker-compose up --build` or `docker compose up --build` from the root of this repo with the correct `.env` file.
44

5+
Please see `.env.example` for an idea of what variables the env file should have.
56

6-
# For devs
7+
The website should be accessible at port 80 and 443
78

8-
TBA
99

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`
1310

api_gateway/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { isLocal } from './proxy/service_addresses';
88
import cors from 'cors';
99

1010
const corsOptions = {
11-
origin: ["http://peerprep-g10.com", "https://peerprep-g10.com", "http://localhost:3000"],
11+
origin: ["http://peerprep-g10.com", "https://peerprep-g10.com", "http://localhost:3000", "http://localhost", "https://localhost"],
1212
methods: ["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"],
1313
optionsSuccessStatus: 200,
1414
credentials: true,

code_execution/src/executor_client.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ import { callbacks, langToId } from "./shared";
44
import { judge0Result, judge0submission, submissionResult } from "./types";
55
import { submitSubmission } from "./submission_client";
66

7-
const JUDGE_API_URL = "http://peerprep-g10.com:2358"; //"https://judge0-ce.p.rapidapi.com";
8-
const API_KEY = process.env.JUDGE0_API_KEY;
7+
const JUDGE_API_URL = "http://judge0:2358"; //"https://judge0-ce.p.rapidapi.com";
98

109
async function submitIndividual(submission: judge0submission) {
1110
const response = await axios.post(

docker-compose.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ services:
66
build:
77
context: ./frontend
88
dockerfile: Dockerfile.prod
9+
args:
10+
- REACT_APP_BACKEND_HOST=${REACT_APP_BACKEND_HOST}
911
image: asia-southeast1-docker.pkg.dev/cs3219-400714/peerprep/frontend:latest
1012
environment:
1113
- REACT_APP_ENV_TYPE=prod
@@ -94,13 +96,13 @@ services:
9496
dockerfile: Dockerfile.prod
9597
environment:
9698
- PORT=8090
97-
- JUDGE0_API_KEY=${JUDGE0_API_KEY}
9899
ports:
99100
- "8090:8090"
100101
volumes:
101102
- questions_test_cases:/app/question_test_cases
102103

103104
judge0-server:
105+
container_name: judge0
104106
image: judge0/judge0:1.13.0
105107
ports:
106108
- "2358:2358"

docker_compose_dev.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ services:
5252
context: ./code_execution
5353
environment:
5454
- PORT=8090
55-
- JUDGE0_API_KEY=${JUDGE0_API_KEY}
5655
ports:
5756
- "8090:8090"
5857
volumes:

frontend/Dockerfile.prod

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,21 @@ FROM node:18-alpine as build
33
WORKDIR /app
44
COPY package.json ./
55
COPY package-lock.json ./
6+
COPY create-env-file.sh ./
67
RUN npm ci
78
COPY . ./
9+
10+
ARG REACT_APP_BACKEND_HOST
11+
12+
RUN sh create-env-file.sh REACT_APP_BACKEND_HOST=$REACT_APP_BACKEND_HOST
813
RUN npm run build
914

1015

1116
# Serve stage
1217
FROM nginx:alpine
18+
COPY nginx.conf /etc/nginx/conf.d/default.conf
1319
COPY --from=build /app/build /usr/share/nginx/html
20+
COPY --from=build /app/.env /usr/share/nginx/html
21+
1422
EXPOSE 80
1523
CMD ["nginx", "-g", "daemon off;"]

frontend/create-env-file.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env bash
2+
#
3+
4+
touch .env
5+
6+
for envvar in "$@"
7+
do
8+
echo "$envvar" >> .env
9+
done

frontend/nginx.conf

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
server {
2+
listen 80;
3+
server_name localhost;
4+
5+
location / {
6+
root /usr/share/nginx/html;
7+
index index.html index.htm;
8+
try_files $uri /index.html;
9+
}
10+
11+
error_page 500 502 503 504 /50x.html;
12+
location = /50x.html {
13+
root /usr/share/nginx/html;
14+
}
15+
}

0 commit comments

Comments
 (0)