4. What is Continuous integration
▷ A development methodology
▷ Verified by builds
○ Unit test
○ Functional test
○ Integration test
▷ Every commit trigger a build
5. What is Continuous delivery
▷ Continuous delivery/deployment
▷ Every commit that passed a build
could be deploy to production
▷ Automation deploy
6. What is Jenkins?
▷ CI/CD application
▷ Easy installation
▷ Rich plugin
▷ Distributed build
15. Node0 set up
▷ Start the Consul container
$ docker run -d -p 8500:8500 -h consul --name consul progrium/consul
-server -bootstrap
Unable to find image 'progrium/consul:latest' locally
latest: Pulling from progrium/consul
3b4d28ce80e4: Pull complete
e5ab901dcf2d: Pull complete
<snip>
16. Node1-3 set up
▷ Edit DOCKER_OPTS daemon
(/etc/default/docker)
DOCKER_OPTS="-H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock
--cluster-store=consul://10.128.0.2:8500/network --cluster-advertise=ens4:2375"
21. Example Voting App
▷ A Python webapp which lets you vote between two options
▷ A Redis queue which collects new votes
▷ A Java worker which consumes votes and stores them in…
▷ A Postgres database backed by a Docker volume
▷ A Node.js webapp which shows the results of the voting in real time
22. Voting App
Dockerfile
# Using official python runtime base image
FROM python:2.7
# Set the application directory
WORKDIR /app
# Install our requirements.txt
ADD requirements.txt /app/requirements.txt
RUN pip install -r requirements.txt
# Copy our code from the current folder to /app inside the container
ADD . /app
# Make port 5000 available for links and/or publish
EXPOSE 80
# Define our command to be run when launching the container
CMD ["python", "app.py"]
23. Result App
Dockerfile
FROM node:0.10
RUN mkdir /app
WORKDIR /app
ADD package.json /app/package.json
RUN npm install && npm ls
RUN mv /app/node_modules /node_modules
ADD . /app
ENV PORT 80
EXPOSE 80
CMD ["node", "server.js"]
24. Worker
Dockerfile
FROM java:7
RUN apt-get update -qq && apt-get install -y maven && apt-get clean
WORKDIR /code
ADD pom.xml /code/pom.xml
RUN ["mvn", "dependency:resolve"]
RUN ["mvn", "verify"]
# Adding source, compile and package into a fat jar
ADD src /code/src
RUN ["mvn", "package"]
CMD ["/usr/lib/jvm/java-7-openjdk-amd64/bin/java", "-jar", "target/worker-jar-with-dependencies.jar"]
33. Deploying The App
root@node2:~# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED
STATUS PORTS NAMES
0100cf6b0c14 engineerball/result-app:47d362f35a115f2098c80a11e161eef626e1dbcb "node server.js" 2 hours ago
Up 2 hours 0.0.0.0:5001->80/tcp voteapps_result-app_1
296eee196e4e engineerball/voting-app:47d362f35a115f2098c80a11e161eef626e1dbcb "python app.py" 2 hours ago
Up 2 hours 0.0.0.0:5000->80/tcp voteapps_voting-app_1
40f8d8aec4ca engineerball/worker:47d362f35a115f2098c80a11e161eef626e1dbcb "/usr/lib/jvm/java-7-" 2 hours ago
Up 2 hours voteapps_worker_1
44da08df3d5c postgres:9.4 "/docker-entrypoint.s" 2 hours ago
Up 2 hours 5432/tcp voteapps_db_1
fa10362631cb redis "docker-entrypoint.sh" 2 hours ago
Up 2 hours 6379/tcp voteapps_redis_1