Skip to content

Commit

Permalink
Merge pull request #114 from iynixil/update-docker
Browse files Browse the repository at this point in the history
Update docker
  • Loading branch information
xuelinglow authored Nov 13, 2024
2 parents 62d47f4 + 77411e3 commit 66a178d
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 16 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,16 @@
- You can choose to develop individual microservices within separate folders within this repository **OR** use individual repositories (all public) for each microservice.
- In the latter scenario, you should enable sub-modules on this GitHub classroom repository to manage the development/deployment **AND** add your mentor to the individual repositories as a collaborator.
- The teaching team should be given access to the repositories as we may require viewing the history of the repository in case of any disputes or disagreements.

### Run PeerPrep with docker-compose:
Prerequisite: Ensure that Docker is installed and running.
1. Clone the repository.
2. Ensure that the respective `.env` files for all microservices, and the frontend, have been added in.
3. In any IDE or terminal, `cd` to the project root directory, and run the following commands:
- `docker-compose build --no-cache` to build the images
- `docker-compose up -d` to run the web app on `localhost:3000`
- `docker-compose down` to stop running the containers

### Production Deployment of PeerPrep
- The production build and deployment of PeerPrep is located under the `deployment` branch.
- Deployment link: http://g46-peerprep-env.eba-u9cm3q7g.ap-southeast-1.elasticbeanstalk.com/
6 changes: 0 additions & 6 deletions backend/feedback-service/package-lock.json

This file was deleted.

56 changes: 46 additions & 10 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,11 @@ services:
container_name: matching-service
environment:
- RABBIT_HOSTNAME=rabbitmq # URL to connect to rabbitmq container in the network
- API_GATEWAY_URL=http://api-gateway:8000
depends_on: # condition to wait for rabbitmq container to be ready
rabbitmq:
condition: service_healthy
build: ./backend/matching-service # Path to the directory containing the Dockerfile for building the matching-service image.
ports:
- 5002:5002 # Maps port 5002 on the host to port 5002 in the container, making the app accessible on the host.
volumes:
- ./backend/matching-service:/app # Mounts the host directory './backend/matching-service' to '/app' in the container.
- /app/node_modules # Anonymous Volume
Expand All @@ -60,23 +59,60 @@ services:

collaboration-service:
container_name: collaboration-service
build: ./backend/collaboration-service # Path to the directory containing the Dockerfile for building the matching-service image.
environment:
- URL_QUESTION_SERVICE=http://question-service:5000/question
- API_GATEWAY_URL=http://api-gateway:8000
build: ./backend/collaboration-service # Path to the directory containing the Dockerfile for building the collaboration-service image.
ports:
- 5003:5003 # Maps port 5002 on the host to port 5002 in the container, making the app accessible on the host.
- 5003:5003 # Maps port 5003 on the host to port 5003 in the container, making the app accessible on the host.
volumes:
- ./backend/collaboration-service:/app # Mounts the host directory './backend/matching-service' to '/app' in the container.
- ./backend/collaboration-service:/app # Mounts the host directory './backend/collaboration-service' to '/app' in the container.
- /app/node_modules # Anonymous Volume
networks:
- peerprep-network # Connects the matching-service to the 'peerprep-network' network.
- peerprep-network # Connects the collaboration-service to the 'peerprep-network' network.

api-gateway:
container_name: api-gateway
environment:
- QUESTION_SERVICE_URL=http://question-service:5000/question
- USER_SERVICE_URL=http://user-service:5001/user
- COLLABORATION_SERVICE_URL=http://collaboration-service:5003/collaboration
depends_on:
question-service:
condition: service_started
user-service:
condition: service_started
collaboration-service:
condition: service_started
build: ./backend/api-gateway # Path to the directory containing the Dockerfile for building the api-gateway image.
ports:
- 8000:8000 # Maps port 8000 on the host to port 8000 in the container, making the app accessible on the host.
volumes:
- ./backend/api-gateway:/app # Mounts the host directory './backend/api-gateway' to '/app' in the container.
- /app/node_modules # Anonymous Volume
networks:
- peerprep-network # Connects the api-gateway to the 'peerprep-network' network.

frontend:
container_name: frontend
environment:
# - QUESTION_SERVICE_URL=question-service
- QUESTION_SERVICE_URL=http://question-service:5000

- REACT_APP_API_GATEWAY_URL=http://localhost:8000
build: ./frontend
ports:
- 3000:3000
volumes:
- ./frontend:/app
- /app/node_modules
networks:
- peerprep-network
depends_on:
- api-gateway

volumes:
rabbitmq_data:

networks:
peerprep-network: # Defines a network named 'peerprep-network'.
name: peerprep-network
driver: bridge # Uses the bridge driver for the network, which is the default and most common network type in Docker.
driver: bridge # Uses the bridge driver for the network, which is the default and most common network type in Docker.
external: true
20 changes: 20 additions & 0 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Use an official Node.js runtime as a parent image
FROM node:20-alpine

# Set the working directory in the container
WORKDIR /app

# Copy package.json and package-lock.json
COPY package*.json ./

# Install any dependencies
RUN npm install

# Bundle app source inside the Docker image
COPY . .

# Make port 3000 available to the world outside this container
EXPOSE 3000

# Define the command to run your app
CMD ["npm", "start"]

0 comments on commit 66a178d

Please sign in to comment.