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

Updated README.md at /react-express-mongodb /backend/ #405

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
20 changes: 11 additions & 9 deletions react-express-mongodb/backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ You will find this `DockerFile` file in the root directory of the project.

```bash
FROM node:13.13.0-stretch-slim
#Argument that is passed from docer-compose.yaml file
#Argument that is passed from docker-compose.yaml file
ARG NODE_PORT
#Echo the argument to check passed argument loaded here correctly
RUN echo "Argument port is : $NODE_PORT"
# Create app directory
WORKDIR /usr/src/app
#COPY . .
COPY . .
# Copy dependency definitions
COPY package.json /usr/src/app
# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm@5+)
RUN npm install
# Get all the code needed to run the app
COPY . /usr/src/app
#In my case my app binds to port NODE_PORT so you'll use the EXPOSE instruction to have it mapped by the docker daemon:
EXPOSE ${NODE_PORT}
CMD npm run dev
Expand All @@ -29,13 +29,15 @@ CMD npm run dev

- On third line we log to check argument is successfully read

- On fourth line we sets a working directory from where the app code will live inside the Docker container.
- On fourth line we set a working directory ,where the app code will be set to present inside the Docker container.

- On fifth line, we are copying/bundling our code working directory into container working directory on line three.
- On fifth line, we are copying our dependency file (i,e package.json) into container working directory which was set on line four.

- On line seven, we run npm install for dependencies in container on line four.
- On sixth line, we run npm install for dependencies installation in container.

- On line seven, we are copying/bundling our code working directory into container working directory which was set on line four.

- On Line eight, we setup the port, that Docker will expose when the container is running. In our case it is the port which we define inside `.env` file, read it from `docker-compose` then passed as a argument to the (backend)`DockerFile`.

- And in last, we tell docker to execute our app inside the container by using node to run `npm run dev. It is the command which I registered in __package.json__ in script section.
- And at last, we tell docker to execute our app inside the container by using node to run `npm run dev. It is the command which I registered in __package.json__ in script section.
###### :clipboard: `Note: For development purpose I used __nodemon__ , If you need to deploy at production you should change CMD from __npm run dev__ to __npm start__.`