Getting started with Node containers
Let's start things off by running the Barely SMS React dev server within a Node.js Docker image. Note that this is not part of the production deployment. This is just a starting point for you to get familiar with deploying Docker containers. As we progress through the remaining sections in this chapter, you'll move steadily toward a production-level deployment.
The first step to getting your React application into a container is creating a Dockerfile
. If you don't have Docker installed on your system already, find it here along with installation instructions: https://www.docker.com/community-edition. If you open up a terminal and change into the getting-started-with-containers
directory, you'll see a file called Dockerfile
. Here's what it looks like:
FROM node:alpine WORKDIR /usr/src/app COPY package*.json ./ RUN npm install COPY . . EXPOSE 3000 CMD [ "npm", "start" ]
This is the file that's used to build an image. An image is like a template for the container...