generated from CS3219-AY2324S1/course-assessment-template
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
71957f2
commit 4f52a4d
Showing
9 changed files
with
114 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
FROM node:16-alpine as builder | ||
WORKDIR './client' | ||
COPY ./package.json ./ | ||
RUN npm install | ||
COPY . . | ||
# RUN npm run build // only use for deployment | ||
EXPOSE 3002 | ||
CMD ["npm", "start"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
services: | ||
user-service: | ||
build: | ||
context: ./user-service | ||
dockerfile: Dockerfile.userservice-backend | ||
ports: | ||
- "3000:3000" | ||
env_file: | ||
- ./user-service/.env | ||
depends_on: | ||
user-service-db: | ||
condition: service_healthy | ||
restart: on-failure | ||
|
||
user-service-db: | ||
build: | ||
context: ./user-service | ||
dockerfile: Dockerfile.postgres-db | ||
env_file: | ||
- ./user-service/.env | ||
healthcheck: | ||
test: [ "CMD-SHELL", "pg_isready -U postgres" ] | ||
interval: 5s | ||
timeout: 3s | ||
retries: 3 | ||
restart: on-failure | ||
|
||
question-service: | ||
build: ./question-service | ||
ports: | ||
- "3001:3001" | ||
depends_on: | ||
- user-service | ||
env_file: | ||
- ./question-service/.env | ||
restart: on-failure | ||
|
||
client: | ||
build: ./client | ||
ports: | ||
- "3002:3002" | ||
depends_on: | ||
- user-service | ||
- question-service | ||
restart: on-failure | ||
# nginx-api-gateway: | ||
# build: ./nginx | ||
# ports: | ||
# - "80:80" | ||
# depends_on: | ||
# - user-service | ||
# - question-service | ||
# - matching-service | ||
# - collaboration-service | ||
# - client | ||
# restart: on-failure |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
FROM alpine:latest | ||
RUN apk update && \ | ||
apk add nodejs npm | ||
RUN npm install -g nodemon | ||
WORKDIR '/question-service' | ||
COPY package*.json ./ | ||
RUN npm install | ||
# RUN npm ci --omit=dev | ||
COPY . . | ||
EXPOSE 3001 | ||
CMD [ "nodemon", "index.js" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,15 @@ | ||
# Starting sev (Dev mode) | ||
# MongoDB question-service setup using docker | ||
|
||
1. Run `npm i` => install all dependencies from package.json | ||
2. Run `nodemon index.js` => hot reloads the event loop | ||
1. Install docker desktop | ||
2. In the root dir question-service/ run `docker build . -t <docker-username>/question-api` | ||
3. Amend container name and port as needed and run the command | ||
`docker run -p 3001:3001 -d <docker-username>/question-api` | ||
|
||
Note: To access docker container: | ||
Use the following link: `http://localhost:3001/` | ||
You should see the following display: `You are on the question api service!` | ||
|
||
# Starting sev (Dev mode) | ||
|
||
1. Run `npm i` => install all dependencies from package.json | ||
2. Run `nodemon index.js` => hot reloads the event loop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
DB_USER=postgres | ||
POSTGRES_PASSWORD=<fill in> | ||
DB_ADDR=localhost | ||
DB_PORT=1111 | ||
DB_ADDR=user-service-db | ||
DB_PORT=5432 | ||
DB_NAME=userservice | ||
JWT_SECRET=<fill in> | ||
ADMIN_PASSWORD=<admin password to login to db fill in> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
FROM node:18 | ||
WORKDIR /userservice | ||
COPY package*.json ./ | ||
RUN npm i | ||
COPY app.ts ./ | ||
COPY tsconfig.json ./ | ||
WORKDIR /userservice/src | ||
COPY src ./ | ||
EXPOSE 3000 | ||
RUN npm run build | ||
CMD ["npm", "run", "start:prod"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,16 @@ | |
|
||
1. Install docker desktop | ||
2. In the root dir user-service/ run `docker build -f Dockerfile.postgres-db -t user-service-psql .` | ||
3. Amend the password, container name and port as needed and run the command | ||
`docker run -p 1111:5432 -e POSTGRES_PASSWORD=<POSTGRES_PASSWORD> --name user-service-db -d user-service-psql` | ||
3. Create user-service container | ||
`docker build -f Dockerfile.userservice-backend -t user-service-backend .` | ||
4. Create network for user-service | ||
`docker network create user-service` | ||
5. Start DB container from image - replace fields | ||
`docker run --env-file=.env --name user-service-db -d --network=user-service user-service-psql` | ||
6. Get DB container IP - copy this value into DB_ADDR in .env | ||
`docker inspect user-service-db | grep IPAddress` | ||
7. Start user-service container from image | ||
`docker run -p 3000:3000 --env-file=.env --name user-service-backend -d --network=user-service user-service-backend` | ||
|
||
# Setup | ||
|
||
|
@@ -25,4 +33,4 @@ | |
### Admin account | ||
|
||
Username: [email protected] | ||
password: Set by ADMIN_PASSWORD field | ||
password: Set by ADMIN_PASSWORD field |