Skip to content

Commit

Permalink
Updated Docker Config
Browse files Browse the repository at this point in the history
- Installed dependencies in Backend container before copying to allow caching
- Installed Node Modules in Frontend container
- Added Node Modules to .dockerignore for Frontend container
- Corrected volume mapping in docker-compose.yml
- Updated port back to 5000 from 4000
  • Loading branch information
Raj Shah committed Sep 28, 2021
1 parent fc8eac4 commit 7087663
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 26 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
13 changes: 7 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# pull official base image
FROM node:14

COPY ./package.json /usr/src/app/package.json
# set working directory
WORKDIR .

# add `/app/node_modules/.bin` to $PATH
WORKDIR /usr/src/app
# install dependencies first so that they can be cached
RUN npm install
EXPOSE 3000

# copy the code
COPY . ./
# start app
CMD ["yarn", "start"]
ENTRYPOINT ["yarn"]
CMD ["start"]
16 changes: 3 additions & 13 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,9 @@
FROM python:3.8
ADD ../ /usr/src/app
COPY ./requirements.txt /usr/src/app/requirements.txt

This comment has been minimized.

Copy link
@shahrk

shahrk Sep 28, 2021

Owner

Only copying requirements.txt initially so that when we run pip install -r requirements.txt a new image gets created with only the requirements. This will allow for caching as this particular image won't have to be rebuilt whenever code changes are made.

WORKDIR /usr/src/app
EXPOSE 4000
RUN pip install --upgrade pip
RUN pip install -r requirements.txt

#FROM node:14.9
#COPY package*.json ./

#RUN npm install

#COPY . .

#EXPOSE 3000

#CMD [ "yarn", "start" ]
COPY . /usr/src/app
EXPOSE 5000
ENTRYPOINT ["python"]
CMD ["index.py"]
12 changes: 7 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,27 @@ services:
backend:
build: ./backend
ports:
- "4000:4000"
- "5000:5000"
volumes:
- .:/backend/app
- ./backend:/usr/src/app

This comment has been minimized.

Copy link
@shahrk

shahrk Sep 28, 2021

Owner

This will allow us to use the docker container without re-building every time code changes are made to files inside the backend folder.

environment:
- ENV=development
- PORT=4000
- PORT=5000
- DB=mongodb+srv://bot:[email protected]/feature-hunt?retryWrites=true&w=majority
#- DB=mongodb://mongodb:27017/todoDev


frontend:
build: .
volumes:
- '/usr/src/app'
- ./src:/usr/src/app/src
- ./public:/usr/src/app/public
- ./test:/usr/src/app/test

This comment has been minimized.

Copy link
@shahrk

shahrk Sep 28, 2021

Owner

This will allow us to use the docker container without re-building every time code changes are made to files inside the src, public, or test folder.

ports:
- 8080:3000
stdin_open: true


networks:
default:
name: web_dev
name: feature_hunt
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"last 1 safari version"
]
},
"proxy": "http://localhost:4000",
"proxy": "http://localhost:5000",
"devDependencies": {
"json-server": "^0.16.3"
}
Expand Down
2 changes: 1 addition & 1 deletion src/Service.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const baseUrl = "http://localhost:4000/";
const baseUrl = "http://localhost:5000/";
const requestOptionsBuilder = (method, body, headers) => {
let options = {
method: method,
Expand Down

0 comments on commit 7087663

Please sign in to comment.