You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Guillaume Lours 4bba832f88
Arm64 and check Compose v2 support (#177)
add support of arm64 architecture for the following samples: 
* aspnet-mssql
* elasticsearch-logstash-kibana
* nginx-aspnet-mysql
* nginx-flask-mysql
* nginx-golang-mysql
* react-java-mysql
* sparkjava-mysql
* wordpress-mysql
* react-express-mysql
* react-express-mongodb

Signed-off-by: Guillaume Lours <guillaume.lours@docker.com>
3 years ago
..
config Fixed typo in message. (#132) 4 years ago
db Arm64 and check Compose v2 support (#177) 3 years ago
logs react-express-mongodb: lint sources 5 years ago
models/todos react-express-mongodb: lint sources 5 years ago
routes react-express-mongodb: lint sources 5 years ago
utils/helpers react-express-mongodb: lint sources 5 years ago
.dockerignore react-express-mongodb: clean frontend code 5 years ago
Dockerfile react-express-mongodb: clean frontend code 5 years ago
README.md
package-lock.json fix issue in validor dependency in the backend of react-express-mongodb sample (#175) 3 years ago
package.json fix issue in validor dependency in the backend of react-express-mongodb sample (#175) 3 years ago
server.js react-express-mongodb: lint sources 5 years ago

README.md

Snippet of backend(Node.js)DockerFile

You will find this DockerFile file in the root directory of the project.

FROM node:13.13.0-stretch-slim
#Argument that is passed from docer-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 . .
# 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
#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
Explanation of backend(Node.js) DockerFile
  • The first line tells Docker to use another Node image from the DockerHub. Were using the official Docker image for Node.js and its version 10 image.

  • On second line we declare argument NODE_PORT which we will pass it from docker-compose.

  • 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 fifth line, we are copying/bundling our code working directory into container working directory on line three.

  • On line seven, we run npm install for dependencies in container 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.

📋 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__.