Skip to content

Commit 74129fc

Browse files
committed
Following steps to dockerise
1 parent 133c64b commit 74129fc

File tree

7 files changed

+47
-11
lines changed

7 files changed

+47
-11
lines changed

backend/question/.env.compose

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
EXPRESS_ENV="compose"
2+
PEERPREP_UI_HOST="http://frontend:3000"
3+
4+
EXPRESS_PORT=9002
5+
EXPRESS_DB_HOST="qn-db"
6+
EXPRESS_DB_PORT=5433
7+
POSTGRES_DB="question"
8+
POSTGRES_USER="peerprep-qn-express"
9+
POSTGRES_PASSWORD="Xk8qEcEI2sizjfEn/lF6mLqiyBECjIHY3q6sdXf9poQ="
10+
PGDATA="/data/qn-db"
11+
12+
EXPRESS_JWT_SECRET_KEY="jd+9qlXA0a3YsmVf2KJgyiJ3SprIR318IAwhRXck4Y8="

backend/question/.env.docker

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
EXPRESS_ENV=local
2+
PEERPREP_UI_HOST=http://localhost:5173
3+
4+
EXPRESS_PORT=9002
5+
EXPRESS_DB_HOST=host.docker.internal
6+
EXPRESS_DB_PORT=5433
7+
POSTGRES_DB=question
8+
POSTGRES_USER=peerprep-qn-express
9+
POSTGRES_PASSWORD=Xk8qEcEI2sizjfEn/lF6mLqiyBECjIHY3q6sdXf9poQ=
10+
PGDATA=/data/qn-db
11+
12+
EXPRESS_JWT_SECRET_KEY=jd+9qlXA0a3YsmVf2KJgyiJ3SprIR318IAwhRXck4Y8=

backend/question/docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ services:
2525
target: build
2626
args:
2727
# For building with the correct env vars
28-
- env=${EXPRESS_ENV}
28+
- port=${EXPRESS_PORT}
2929
ports:
30-
- "9002:8001"
30+
- "9001:${EXPRESS_PORT}"
3131
command: node dist/index.js
3232
env_file:
3333
- ./.env.local

backend/question/entrypoint.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/sh
2+
3+
# Drizzle will handle its own logic to remove conflicts
4+
npm run db:prod:migrate
5+
6+
# Checks admin table and will not seed if data exists
7+
npm run db:prod:seed
8+
9+
npm run start

backend/question/express.Dockerfile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ COPY --from=build /data/question-express/package*.json ./
1111
RUN npm ci --omit=dev
1212
COPY --from=build --chown=node:node /data/question-express/dist ./dist
1313

14-
ARG env
15-
COPY ".env.${env}" .
16-
EXPOSE 8001
14+
ARG port
15+
EXPOSE ${port}
1716
CMD [ "npm", "run", "start" ]

backend/question/package.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@
44
"main": "dist/index.js",
55
"scripts": {
66
"dev": "env-cmd -f .env.local nodemon src/index.ts | pino-pretty",
7-
"build": "env-cmd -f .env.local tsc && tsc-alias",
8-
"start": "env-cmd -f .env.local node dist/index.js",
9-
"build:prod": "env-cmd -f .env.prod tsc && tsc-alias",
10-
"start:prod": "env-cmd -f .env.local node dist/index.js",
7+
"build": "tsc && tsc-alias",
8+
"start": "node dist/index.js",
9+
"build:local": "env-cmd -f .env.local tsc && tsc-alias",
10+
"start:local": "env-cmd -f .env.local node dist/index.js",
1111
"db:generate": "env-cmd -f .env.local drizzle-kit generate",
1212
"db:migrate": "env-cmd -f .env.local tsx ./src/lib/db/migrate.ts",
1313
"db:seed": "env-cmd -f .env.local tsx ./src/lib/db/seed.ts",
14+
"db:prod:migrate": "tsx ./src/lib/db/migrate.ts",
15+
"db:prod:seed": "tsx ./src/lib/db/seed.ts",
1416
"db:inspect": "env-cmd -f .env.local drizzle-kit studio",
1517
"fmt": "prettier --config .prettierrc src --write",
1618
"test": "echo \"Error: no test specified\" && exit 1"
@@ -21,6 +23,7 @@
2123
"description": "",
2224
"dependencies": {
2325
"cors": "^2.8.5",
26+
"dotenv": "^16.4.5",
2427
"drizzle-orm": "^0.33.0",
2528
"env-cmd": "^10.1.0",
2629
"express": "^4.21.0",
@@ -33,6 +36,7 @@
3336
"devDependencies": {
3437
"@swc/core": "^1.7.26",
3538
"@swc/helpers": "^0.5.13",
39+
"@types/cors": "^2.8.17",
3640
"@types/express": "^4.17.21",
3741
"@types/node": "^22.5.5",
3842
"drizzle-kit": "^0.24.2",

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)