Skip to content

Commit 71b883a

Browse files
committed
Merge branch 'development' of https://github.com/ruiqi7/peer-prep into bugfix/general
2 parents 87089d8 + d4009ba commit 71b883a

Some content is hidden

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

54 files changed

+610
-118
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ jobs:
2929
run: npm run lint
3030
- name: Test
3131
run: docker compose -f docker-compose-test.yml run --rm test-frontend
32+
- name: Build
33+
run: docker compose -f docker-compose-prod.yml build frontend
3234
backend-ci:
3335
runs-on: ubuntu-latest
3436
strategy:
@@ -65,3 +67,5 @@ jobs:
6567
JWT_SECRET: ${{ secrets.JWT_SECRET }}
6668
ONE_COMPILER_KEY: ${{ secrets.ONE_COMPILER_KEY }}
6769
run: docker compose -f docker-compose-test.yml run --rm test-${{ matrix.service }}
70+
- name: Build
71+
run: docker compose -f docker-compose-prod.yml build ${{ matrix.service }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ node_modules
1111
dist
1212
dist-ssr
1313
*.local
14+
*.tsbuildinfo
1415

1516
# Coverage
1617
coverage

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,26 @@ To stop all the services, use the following command:
2424
docker-compose down
2525
```
2626

27+
## Running in Production Mode
28+
29+
1. Build all the services (without using cache).
30+
31+
```
32+
docker-compose -f docker-compose-prod.yml build --no-cache
33+
```
34+
35+
2. Run all the services (in detached mode).
36+
37+
```
38+
docker-compose -f docker-compose-prod.yml up -d
39+
```
40+
41+
To stop all the services, use the following command:
42+
43+
```
44+
docker-compose -f docker-compose-prod.yml down
45+
```
46+
2747
## Useful links
2848

2949
- User Service: http://localhost:3001

backend/code-execution-service/.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ node_modules
33
tests
44
.env*
55
*.md
6+
dist

backend/code-execution-service/Dockerfile

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM node:20-alpine
1+
FROM node:20-alpine AS base
22

33
WORKDIR /code-execution-service
44

@@ -10,4 +10,16 @@ COPY . .
1010

1111
EXPOSE 3004
1212

13+
# DEV
14+
15+
FROM base AS dev
16+
1317
CMD ["npm", "run", "dev"]
18+
19+
# PROD
20+
21+
FROM base AS prod
22+
23+
RUN npm run build
24+
25+
CMD ["npm", "start"]

backend/code-execution-service/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
"main": "server.ts",
55
"type": "module",
66
"scripts": {
7-
"start": "tsx server.ts",
8-
"dev": "tsx watch server.ts",
7+
"start": "tsx dist/server.js",
8+
"dev": "tsx watch src/server.ts",
9+
"build": "tsc",
910
"test": "cross-env NODE_ENV=test && jest",
1011
"test:watch": "cross-env NODE_ENV=test && jest --watch",
1112
"lint": "eslint ."

backend/code-execution-service/app.ts renamed to backend/code-execution-service/src/app.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import yaml from "yaml";
55
import swaggerUi from "swagger-ui-express";
66
import cors from "cors";
77

8-
import codeExecutionRoutes from "./src/routes/codeExecutionRoutes.ts";
8+
import codeExecutionRoutes from "./routes/codeExecutionRoutes";
99

1010
dotenv.config();
1111

File renamed without changes.

backend/code-execution-service/tsconfig.json

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
1212

1313
/* Language and Environment */
14-
"target": "ES2017" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
14+
"target": "es2016" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
1515
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
1616
// "jsx": "preserve", /* Specify what JSX code is generated. */
1717
// "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
@@ -26,7 +26,7 @@
2626

2727
/* Modules */
2828
"module": "ESNext" /* Specify what module code is generated. */,
29-
// "rootDir": "./", /* Specify the root folder within your source files. */
29+
"rootDir": "./src" /* Specify the root folder within your source files. */,
3030
"moduleResolution": "Node" /* Specify how TypeScript looks up a file from a given module specifier. */,
3131
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
3232
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
@@ -35,7 +35,7 @@
3535
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
3636
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
3737
// "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
38-
"allowImportingTsExtensions": true /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */,
38+
// "allowImportingTsExtensions": true /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */,
3939
// "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */
4040
// "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */
4141
// "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */
@@ -55,9 +55,9 @@
5555
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
5656
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
5757
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
58-
"noEmit": true /* Disable emitting files from a compilation. */,
58+
// "noEmit": true, /* Disable emitting files from a compilation. */
5959
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
60-
// "outDir": "./", /* Specify an output folder for all emitted files. */
60+
"outDir": "./dist" /* Specify an output folder for all emitted files. */,
6161
// "removeComments": true, /* Disable emitting comments. */
6262
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
6363
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
@@ -106,5 +106,7 @@
106106
/* Completeness */
107107
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
108108
"skipLibCheck": true /* Skip type checking all .d.ts files. */
109-
}
109+
},
110+
"include": ["src/**/*"],
111+
"exclude": ["node_modules", "dist"]
110112
}

backend/collab-service/.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ node_modules
33
tests
44
.env*
55
*.md
6+
dist

0 commit comments

Comments
 (0)