generated from CS3219-AY2324S1/course-assessment-template
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #46 from CS3219-AY2324S1/Assignment4
Assignment4
- Loading branch information
Showing
6 changed files
with
91 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Getting Started with Docker for Development | ||
|
||
1. Install docker at https://www.docker.com/ | ||
|
||
2. Start docker | ||
|
||
3. Run `docker compose build` to build the images and containers | ||
|
||
4. Run `docker compose up` to start the container (Note: this will only start the user & question service) | ||
|
||
5. Note: this does not start the api-gateway. Follow the relevant `./gateway/README.md` | ||
|
||
## Developer guide | ||
|
||
As of the last update of this README, only the user-service and question-service have been dockerized. A respective `Dockerfile` has been created within each of their folders. This `Dockerfile` specifies the instructions in order to build the container, install the necessary node modules etc. | ||
|
||
To simplify the container building, a `docker-compose.yml` has been created in order to start both containers at once. This is achieved through running `docker compose build` and `docker compose up` to call both dockerfiles. | ||
|
||
The api-gateway requires more work, see https://dev.to/naseef012/create-a-microservices-app-with-dockerized-express-api-gateway-1kf9 for more information. | ||
|
||
## Finishing Development | ||
|
||
When you are done with developing, kill the program (Ctrl^C) and run `docker compose down`. This cleans up local resources used by docker. | ||
|
||
Note: For Mac users, this doesn't work and volumes will continue to pile up. Run `docker system prune -a --volumes` occasionally to remove the remaining volumes. |
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,21 @@ | ||
# Referenced from https://nodejs.org/en/docs/guides/nodejs-docker-webapp | ||
FROM node:20 | ||
|
||
# Create app directory | ||
WORKDIR /app | ||
|
||
# Install app dependencies | ||
# A wildcard is used to ensure both package.json AND package-lock.json are copied | ||
# where available (npm@5+) | ||
COPY ./backend/user-service/package*.json . | ||
RUN npm install | ||
# If you are building your code for production | ||
# RUN npm ci --omit=dev | ||
|
||
COPY ./backend/user-service . | ||
|
||
EXPOSE 3001 | ||
|
||
RUN npx prisma generate --schema /app/prisma/schema.prisma | ||
|
||
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,22 @@ | ||
version: '3.8' | ||
|
||
services: | ||
users: | ||
container_name: user-service | ||
build: | ||
context: . | ||
dockerfile: ./backend/user-service/Dockerfile | ||
ports: | ||
- "3001:3001" | ||
env_file: | ||
- ./backend/user-service/.env | ||
|
||
questions: | ||
container_name: question-service | ||
build: | ||
context: . | ||
dockerfile: ./mongodb-database/Dockerfile | ||
ports: | ||
- "3002:3002" | ||
env_file: | ||
- ./mongodb-database/.env |
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,20 @@ | ||
# Referenced from https://nodejs.org/en/docs/guides/nodejs-docker-webapp | ||
FROM node:20 | ||
|
||
# Create app directory | ||
WORKDIR /app | ||
|
||
# Install app dependencies | ||
# A wildcard is used to ensure both package.json AND package-lock.json are copied | ||
# where available (npm@5+) | ||
COPY ./mongodb-database/package*.json . | ||
RUN npm install | ||
|
||
# If you are building your code for production | ||
# RUN npm ci --omit=dev | ||
|
||
COPY ./mongodb-database . | ||
|
||
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