Docker Lesson 6 — Creating a Production-Grade Workflow
Sep 9, 2018 · 2 min read
It’s the note for Docker and Kubernetes: The Complete Guide
https://www.udemy.com/docker-and-kubernetes-the-complete-guide/
Development -> Testing -> Deployment -> ...(circle)--
Dev - Create / Change features
- Make changes on a non-master branch
* Push to github
* Create Pull Request to merge with masterTest - Code pushed to Travis CI
- Tests run
* Merge PR with masterProd - Code pushed to Travis CI
- Tests run
- Deploy to AWS Elastic Beanstalk--Something to notice...
- Last diagram didn't mention anything about Docker!
- Docker is a tool in a normal development flow
- Docker makes some of these tasks a lot easier--npm run start => Starts up a development server. For development
use only
npm run test => Runs tests associated with the project
npm run build => Builds a production version of the application--In Development
- Docker Container
- npm run startIn Production
- Docker Container
- npm run build
--$ docker build -f <dockerfilename> .EXAMPLE:$ docker build -f Dockerfile.dev .--volume
# -v /app/node_modules => put a bookmark on the node_modules
folder
# -v $(pwd):/app => Map the pwd into the '/app' folder$ docker run -p 3000:3000 -v /app/node_modules -v $(pwd):/app <image_id>--$ docker run -it b8cv8ddjsufos npm run test--$ docker attach <container id>--$ docker exec -it <container id> sh
Practice Steps
Build Phase
- Use node:alpine
- Copy the package.json file
- Install dependencies
- Run
npm run build - Start nginx
Run Phase
- Use nginx
- Copy over the result of
npm run build - Start nginx
DockerfileFROM node:alpine as builder
WORKDIR '/app'
COPY package.json .
RUN npm install
COPY . .
RUN npm run buildFROM nginx
COPY --from=builder /app/build /usr/share/nginx/html
--$ docker build .
$ docker run -p 8080:80 9c476209a066--
