Professional Documents
Culture Documents
https://hackernoon.com/continuous-delivery-of-react-app-with-jenkins-and-docker-8a1ae1511b86 1/34
16/01/2020 Continuous delivery of react app with Jenkins and Docker - By
If your project is open source — you can use Travis CI. You just need to
create .travis.yml like this:
language: node_js
node_js:
- "8"
- "9"
script:
- npm test
https://hackernoon.com/continuous-delivery-of-react-app-with-jenkins-and-docker-8a1ae1511b86 2/34
16/01/2020 Continuous delivery of react app with Jenkins and Docker - By
But I want to show you how to create CI/CD environment from scratch.
We will use Jenkins with Docker. Jenkins has of cial image on docker
hub.
Jenkins
To run Jenkins using of cial image from docker hub we need to run next
command:
https://hackernoon.com/continuous-delivery-of-react-app-with-jenkins-and-docker-8a1ae1511b86 3/34
16/01/2020 Continuous delivery of react app with Jenkins and Docker - By
We will use docker not only for running Jenkins. With docker we can run
docker registry and we can test and create images for our react app.
Registry
Docker compose
But before I’ll create Docker le for Jenkins. We need it for running
docker inside docker.
touch Dockerfile
And put:
FROM jenkins/jenkins:lts
USER root
https://hackernoon.com/continuous-delivery-of-react-app-with-jenkins-and-docker-8a1ae1511b86 4/34
16/01/2020 Continuous delivery of react app with Jenkins and Docker - By
touch docker-compose.yml
And one more. As we need to run docker inside docker we need to add
more volumes. But rst run command:
which docker
version: '3'
services:
jenkins:
build: .
container_name: jenkins
privileged: true
restart: always
ports:
- 8080:8080
volumes:
- ./jenkins_home:/var/jenkins_home
- /var/run/docker.sock:/var/run/docker.sock
- /usr/local/bin/docker:/usr/bin/docker
https://hackernoon.com/continuous-delivery-of-react-app-with-jenkins-and-docker-8a1ae1511b86 5/34
16/01/2020 Continuous delivery of react app with Jenkins and Docker - By
registry:
image: registry
container_name: registry
restart: always
ports:
- 5000:5000
To run it use
docker-compose up -d
And to stop:
docker-compose stop
https://hackernoon.com/continuous-delivery-of-react-app-with-jenkins-and-docker-8a1ae1511b86 6/34
16/01/2020 Continuous delivery of react app with Jenkins and Docker - By
Open http://localhost:8000/:
https://hackernoon.com/continuous-delivery-of-react-app-with-jenkins-and-docker-8a1ae1511b86 7/34
16/01/2020 Continuous delivery of react app with Jenkins and Docker - By
https://hackernoon.com/continuous-delivery-of-react-app-with-jenkins-and-docker-8a1ae1511b86 8/34
16/01/2020 Continuous delivery of react app with Jenkins and Docker - By
https://hackernoon.com/continuous-delivery-of-react-app-with-jenkins-and-docker-8a1ae1511b86 9/34
16/01/2020 Continuous delivery of react app with Jenkins and Docker - By
https://hackernoon.com/continuous-delivery-of-react-app-with-jenkins-and-docker-8a1ae1511b86 10/34
16/01/2020 Continuous delivery of react app with Jenkins and Docker - By
https://hackernoon.com/continuous-delivery-of-react-app-with-jenkins-and-docker-8a1ae1511b86 11/34
16/01/2020 Continuous delivery of react app with Jenkins and Docker - By
https://hackernoon.com/continuous-delivery-of-react-app-with-jenkins-and-docker-8a1ae1511b86 12/34
16/01/2020 Continuous delivery of react app with Jenkins and Docker - By
https://hackernoon.com/continuous-delivery-of-react-app-with-jenkins-and-docker-8a1ae1511b86 13/34
16/01/2020 Continuous delivery of react app with Jenkins and Docker - By
https://hackernoon.com/continuous-delivery-of-react-app-with-jenkins-and-docker-8a1ae1511b86 14/34
16/01/2020 Continuous delivery of react app with Jenkins and Docker - By
Next we need to create a new build. You can make it from start page:
https://hackernoon.com/continuous-delivery-of-react-app-with-jenkins-and-docker-8a1ae1511b86 15/34
16/01/2020 Continuous delivery of react app with Jenkins and Docker - By
On rst step we need to enter name and choose type of our build
con gurations:
https://hackernoon.com/continuous-delivery-of-react-app-with-jenkins-and-docker-8a1ae1511b86 16/34
16/01/2020 Continuous delivery of react app with Jenkins and Docker - By
https://hackernoon.com/continuous-delivery-of-react-app-with-jenkins-and-docker-8a1ae1511b86 17/34
16/01/2020 Continuous delivery of react app with Jenkins and Docker - By
https://hackernoon.com/continuous-delivery-of-react-app-with-jenkins-and-docker-8a1ae1511b86 18/34
16/01/2020 Continuous delivery of react app with Jenkins and Docker - By
https://hackernoon.com/continuous-delivery-of-react-app-with-jenkins-and-docker-8a1ae1511b86 19/34
16/01/2020 Continuous delivery of react app with Jenkins and Docker - By
https://hackernoon.com/continuous-delivery-of-react-app-with-jenkins-and-docker-8a1ae1511b86 20/34
16/01/2020 Continuous delivery of react app with Jenkins and Docker - By
Con gs
Next step is creating Jenkins le, Docker le, Docker le.test and save it
on github:
node {
try {
stage('Checkout') {
checkout scm
}
stage('Environment') {
sh 'git --version'
echo "Branch: ${env.BRANCH_NAME}"
sh 'docker -v'
sh 'printenv'
}
stage('Build Docker test'){
sh 'docker build -t react-test -f Dockerfile.test --no-cache .'
}
stage('Docker test'){
sh 'docker run --rm react-test'
}
stage('Clean Docker test'){
sh 'docker rmi react-test'
}
stage('Deploy'){
if(env.BRANCH_NAME == 'master'){
sh 'docker build -t react-app --no-cache .'
sh 'docker tag react-app localhost:5000/react-app'
https://hackernoon.com/continuous-delivery-of-react-app-with-jenkins-and-docker-8a1ae1511b86 21/34
16/01/2020 Continuous delivery of react app with Jenkins and Docker - By
Docker le
# Extending image
FROM node:carbon
# Versions
RUN npm -v
RUN node -v
# Port to listener
EXPOSE 3000
# Environment variables
ENV NODE_ENV production
ENV PORT 3000
ENV PUBLIC_PATH "/"
# Main command
CMD [ "npm", "run", "start:server" ]
Docker le.test
# Extending image
FROM node:carbon
https://hackernoon.com/continuous-delivery-of-react-app-with-jenkins-and-docker-8a1ae1511b86 22/34
16/01/2020 Continuous delivery of react app with Jenkins and Docker - By
# Versions
RUN npm -v
RUN node -v
# Environment variables
ENV NODE_ENV test
# Main command
CMD [ "npm", "test" ]
And logs:
https://hackernoon.com/continuous-delivery-of-react-app-with-jenkins-and-docker-8a1ae1511b86 23/34
16/01/2020 Continuous delivery of react app with Jenkins and Docker - By
https://hackernoon.com/continuous-delivery-of-react-app-with-jenkins-and-docker-8a1ae1511b86 24/34
16/01/2020 Continuous delivery of react app with Jenkins and Docker - By
https://hackernoon.com/continuous-delivery-of-react-app-with-jenkins-and-docker-8a1ae1511b86 25/34
16/01/2020 Continuous delivery of react app with Jenkins and Docker - By
https://hackernoon.com/continuous-delivery-of-react-app-with-jenkins-and-docker-8a1ae1511b86 26/34
16/01/2020 Continuous delivery of react app with Jenkins and Docker - By
Now we can check that our image stored in our registry. Run command:
https://hackernoon.com/continuous-delivery-of-react-app-with-jenkins-and-docker-8a1ae1511b86 27/34
16/01/2020 Continuous delivery of react app with Jenkins and Docker - By
https://hackernoon.com/continuous-delivery-of-react-app-with-jenkins-and-docker-8a1ae1511b86 28/34
16/01/2020 Continuous delivery of react app with Jenkins and Docker - By
https://hackernoon.com/continuous-delivery-of-react-app-with-jenkins-and-docker-8a1ae1511b86 29/34
16/01/2020 Continuous delivery of react app with Jenkins and Docker - By
In next articles I’ll show how to use SSR, modular structure, webpack
optimization, chaos monkey, testing and code coverage…
# Continuous Delivery
Evheniy Bystrov
# React
Evheniy Bystrov
https://hackernoon.com/continuous-delivery-of-react-app-with-jenkins-and-docker-8a1ae1511b86 30/34
16/01/2020 Continuous delivery of react app with Jenkins and Docker - By
# Javascript
Evheniy Bystrov
Oct 23
# Docker
Evheniy Bystrov
Oct 18
# Javascript
https://hackernoon.com/continuous-delivery-of-react-app-with-jenkins-and-docker-8a1ae1511b86 31/34
16/01/2020 Continuous delivery of react app with Jenkins and Docker - By
Evheniy Bystrov
# React
Email Address *
TOPICS OF INTEREST
https://hackernoon.com/continuous-delivery-of-react-app-with-jenkins-and-docker-8a1ae1511b86 32/34
16/01/2020 Continuous delivery of react app with Jenkins and Docker - By
Peter Jausovec
May 02
# Docker
javinpaul
Oct 05
# React
Chris Chinchilla
# Continuous Integration
https://hackernoon.com/continuous-delivery-of-react-app-with-jenkins-and-docker-8a1ae1511b86 33/34
16/01/2020 Continuous delivery of react app with Jenkins and Docker - By
Marko Anastasov
Sep 10
# Serverless
Buddy
Jul 06
# Docker
https://hackernoon.com/continuous-delivery-of-react-app-with-jenkins-and-docker-8a1ae1511b86 34/34