Workshop Steps - SamirTalwar/the-tiniest-service GitHub Wiki
-
Beforehand:
- "If you're on Windows or Mac, download and install boot2docker [>= 1.5] and run
boot2docker init
." - "If you're on Linux, install Docker [>= 1.5]."
- "Make sure you can run the command
docker run --rm -it busybox echo Hello
."
- "If you're on Windows or Mac, download and install boot2docker [>= 1.5] and run
-
Fork and clone this repository .
-
[Facilitators] A bit of explanation while everyone gets that cloned. [10 minutes]
- Explain Docker.
- Explain the web service.
-
Deploy the application locally using Docker. [30 minutes]
-
Write a Dockerfile using the busybox base image. [15 minutes]
You care about the following commands: FROM, EXPOSE, COPY, RUN and ENTRYPOINT. Go to the docs at http://docs.docker.com/reference/builder/ and start writing your Dockerfile.
-
Come up with a name for your excellent service!
-
Build your Docker image.
docker build --tag=$YOURNAME . docker images
-
Let's run your Docker container.
docker run --rm -it -p 8080:8080 --name=$YOURNAME $YOURNAME
-
Check out your web service at http://$(boot2docker ip):8080/ .
-
Commit!
-
-
Deploy the container remotely.
-
Re-tag the image to include the Docker Hub username provided, using
docker tag
. -
Push the image to Docker Hub using
docker push
. Enter the password when prompted. -
Run your container as before but on the remote host using the
-H
switch, pointing to tcp://services.samirtalwar.com:2375. Don't reserve yourself a specific port!You may need to
unset DOCKER_TLS_VERIFY
, andexport DOCKER_TLS_VERIFY=1
when you need to talk to your local node. This becomes easier if you use separate shells for local and remote Docker management. -
Find out which port is being forwarded using
docker port
. -
Check it out!
-
-
Configure Nginx to behave as a reverse proxy for your container.
-
Fork the provided Nginx configuration repository.
-
Create your server configuration in the appropriate section of the nginx.conf file and raise a pull request.
-
Once your build is green, prod one of the facilitators to merge it.
-
Once the nginx deployment job has run on jenkins, you should be able to access your service via http://web.samirtalwar.com/service-name.
-
-
Configure Nagios to monitor your service.
-
Fork the provided Nagios configuration repository.
-
Create your server configuration in an appropriately named config file and raise a pull request.
-
Once your build is green, prod one of the facilitators to merge it.
-
Once the nagios deployment job has run on Jenkins, you should be able to monitor your service through http://web.samirtalwar.com:8080.
-
-
Continuously deploy your service.
-
Create a test case that ensures your service works. There is an example in a branch on the main repository.
-
Stop and remove your service.
-
Create a new Jenkins job that points to your Git repository.
#!/bin/sh TAG=zero2continuousdeployment/example SERVICE=example ./test docker build --tag=$TAG . docker push $TAG export DOCKER_HOST=tcp://services.samirtalwar.com:2375 docker pull $TAG docker stop $SERVICE && docker rm $SERVICE || : docker run -d -P --name=$SERVICE $TAG
-
Run it.
-
Figure out what the new port is, and observe Nagios cry.
-