We will setup containerization which has nodes, angular2 using docker. In here how we can deploy a simple nodes app which is built using angular2 and how it get deployed using docker on your local machine. i will provide you link to the source you need to just check out the source code and run few commands.
check out how to setup docker on mac here
- Checkout the project from git repo pig latin.
- You can open your project on any of your IDE i used VSC(visual source code) or ATOM.
- Create a docker file with a name DockerFile in the project adjacent to package.jason.
- Content of your docker file would be
FROM node:boron# Create app directoryWORKDIR /src/app# Install app dependenciesCOPY package.json .# For npm@5 or later, copy package-lock.json as well# COPY package.json package-lock.json .RUN npm install# Bundle app sourceCOPY . .EXPOSE 3001CMD [ “npm”, “start” ]
5. Now form terminal/cmdline navigate location where docker file is there.
6. Run command (don’t forget the “.”)
docker build -t username/pig latin .
7. Run command to see docker image created.
docker images
8. Now its time to run your docker container
docker run -p 3001:3001 -d username/piglatin
9. To see your docker container running run command
docker ps or docker ps -a (in case container dies due to some issue)
10. you will see something like this.
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
afd13d0898ff nshah/piglatin “npm start” 2 days ago Up 2 days 0.0.0.0:3001->3001/tcp priceless_jang
11. Request url localhost:3001 and see the app running through your container.