Create a Docker Image

In this section you will learn about how you can create a docker image of the project.

Here are the step by step instructions to make a docker image.

1. Install docker container in your machine.

2. Create a Dockerfile under the project file.

Dockerfile
# You should always specify a full version here to ensure all of your developers
# are running the same version of Node.
FROM node:8.11.2

# The base node image sets a very verbose log level.
ENV NPM_CONFIG_LOGLEVEL warn

# Copy all local files into the image.
COPY . .

# install
RUN npm install

# Build for production.
RUN npm run build

# Set the command to start the node server.
CMD serve -s dist

# Tell Docker about the port we'll run on.
EXPOSE 5000

2. Build your image by running docker build -t reactify-docker . .

3. Verify that it’s working by running docker run -it --rm -p 5000:5000 --name reactify-docker reactify-docker

Check more details about it.

Last updated