Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dockerized the whole application #652

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
run-dev:
docker-compose up
1 change: 1 addition & 0 deletions backend/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
20 changes: 20 additions & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Dockerfile for Node Express Backend

FROM node:14-alpine

# Create App Directory
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app

# Install Dependencies
COPY package*.json ./

RUN npm install

# Copy app source code
COPY . .

# Exports
EXPOSE 3500

CMD ["npm","start"]
5 changes: 5 additions & 0 deletions backend/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# "make build" will give us the backend image
build:
docker build -t api-server .


58 changes: 58 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
version: "3.7"

services:
api-server:
build:
context: ./backend/
dockerfile: Dockerfile
image: api-server
container_name: myapp-node-server
command: /usr/src/app/node_modules/.bin/nodemon index.js
volumes:
- ./backend/:/usr/src/app
- /usr/src/app/node_modules
ports:
- "3500:3500"
depends_on:
- mongo
env_file: ./backend/.env
environment:
- NODE_ENV=development
networks:
- community-app
mongo:
image: mongo:4.4-bionic
volumes:
- mongo-data:/data/db
ports:
- "27017:27017"
networks:
- community-app
react-app:
build:
context: ./frontend/
dockerfile: Dockerfile
image: react-app
stdin_open: true
container_name: myapp-react-frontend
command: npm start
volumes:
- ./frontend/:/usr/src/app
- /usr/src/app/node_modules
depends_on:
- api-server
ports:
- "3000:3000"
networks:
- community-app

networks:
community-app:
driver: bridge

volumes:
mongo-data:
driver: local
node_modules:
web-root:
driver: local
1 change: 1 addition & 0 deletions frontend/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
20 changes: 20 additions & 0 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Dockerfile for React client

# Build react client
FROM node:14-alpine

# Working directory be app
WORKDIR /usr/src/app

COPY package*.json ./

### Installing dependencies

RUN npm install

# copy local files to app folder
COPY . .

EXPOSE 3000

CMD ["npm","start"]
5 changes: 5 additions & 0 deletions frontend/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# "make build" will give us the frontend image
build:
docker build -t react-app .


65 changes: 65 additions & 0 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
"bootstrap": "^4.5.3",
"bootstrap-social": "^5.1.1",
"font-awesome": "^4.7.0",
"joi": "^17.4.0",
"joi-browser": "^13.4.0",
"joi-phone-number": "^5.0.1",
"jwt-decode": "^3.1.2",
"mdbreact": "^5.0.1",
"node-sass": "^4.14.1",
Expand Down
Loading