Skip to content

Commit 9f62784

Browse files
authored
Merge pull request #154 from CS3219-AY2425S1/enhancement/dockerise-user-service
Containerise User Service with Docker
2 parents ca791a5 + aad8aff commit 9f62784

File tree

5 files changed

+43
-9
lines changed

5 files changed

+43
-9
lines changed

.env.sample

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,13 @@ BUILD_ENV=dev
44
# Question service variables
55
QUESTION_SVC_PORT=8001
66
QUESTION_SVC_DB_URI=
7+
8+
9+
# User service variables
10+
USER_SVC_ENV=PROD
11+
USER_SVC_PORT=3001
12+
USER_SVC_DB_URI=
13+
USER_SVC_DB_LOCAL_URI=
14+
JWT_SECRET=
15+
EMAIL_ADDRESS=
16+
EMAIL_PASSWORD=

docker-compose.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,21 @@ services:
88
environment:
99
- PORT=$QUESTION_SVC_PORT
1010
- DB_CLOUD_URI=$QUESTION_SVC_DB_URI
11+
12+
user-service:
13+
build:
14+
context: ./user-service
15+
target: $BUILD_ENV
16+
ports:
17+
- $USER_SVC_PORT:$USER_SVC_PORT
18+
environment:
19+
- ENV=$USER_SVC_ENV
20+
- PORT=$USER_SVC_PORT
21+
- DB_CLOUD_URI=$USER_SVC_DB_URI
22+
- DB_LOCAL_URI=$USER_SVC_DB_LOCAL_URI
23+
- JWT_SECRET=$JWT_SECRET
24+
- EMAIL_ADDRESS=$EMAIL_ADDRESS
25+
- EMAIL_PASSWORD=$EMAIL_PASSWORD
26+
volumes:
27+
- ./user-service:/app
28+
- /app/node_modules

user-service/.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.env
2+
node_modules

user-service/.env.sample

Lines changed: 0 additions & 9 deletions
This file was deleted.

user-service/Dockerfile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM node:20-alpine AS dev
2+
WORKDIR /app
3+
COPY package*.json ./
4+
RUN npm install
5+
COPY . .
6+
CMD ["npm", "run", "dev"]
7+
8+
FROM node:20-alpine AS prod
9+
WORKDIR /app
10+
COPY package*.json ./
11+
RUN npm ci --only=production
12+
COPY . .
13+
CMD ["npm", "start"]

0 commit comments

Comments
 (0)