mirror of
https://github.com/docker/awesome-compose.git
synced 2025-04-19 15:28:06 +02:00
Merge c2071c0e14
into 18f59bdb09
This commit is contained in:
commit
f7d4a8ad3c
1 changed files with 11 additions and 9 deletions
|
@ -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
|
||||
|
@ -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__.`
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue