Workshop Steps - SamirTalwar/the-tiniest-service GitHub Wiki

  1. Beforehand:

    1. "If you're on Windows or Mac, download and install boot2docker [>= 1.5] and run boot2docker init."
    2. "If you're on Linux, install Docker [>= 1.5]."
    3. "Make sure you can run the command docker run --rm -it busybox echo Hello."
  2. Fork and clone this repository .

  3. [Facilitators] A bit of explanation while everyone gets that cloned. [10 minutes]

    1. Explain Docker.
    2. Explain the web service.
  4. Deploy the application locally using Docker. [30 minutes]

    1. 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.

    2. Come up with a name for your excellent service!

    3. Build your Docker image.

       docker build --tag=$YOURNAME .
       docker images
      
    4. Let's run your Docker container.

       docker run --rm -it -p 8080:8080 --name=$YOURNAME $YOURNAME
      
    5. Check out your web service at http://$(boot2docker ip):8080/ .

    6. Commit!

  5. Deploy the container remotely.

    1. Re-tag the image to include the Docker Hub username provided, using docker tag.

    2. Push the image to Docker Hub using docker push. Enter the password when prompted.

    3. 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, and export 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.

    4. Find out which port is being forwarded using docker port.

    5. Check it out!

  6. Configure Nginx to behave as a reverse proxy for your container.

    1. Fork the provided Nginx configuration repository.

    2. Create your server configuration in the appropriate section of the nginx.conf file and raise a pull request.

    3. Once your build is green, prod one of the facilitators to merge it.

    4. Once the nginx deployment job has run on jenkins, you should be able to access your service via http://web.samirtalwar.com/service-name.

  7. Configure Nagios to monitor your service.

    1. Fork the provided Nagios configuration repository.

    2. Create your server configuration in an appropriately named config file and raise a pull request.

    3. Once your build is green, prod one of the facilitators to merge it.

    4. Once the nagios deployment job has run on Jenkins, you should be able to monitor your service through http://web.samirtalwar.com:8080.

  8. Continuously deploy your service.

    1. Create a test case that ensures your service works. There is an example in a branch on the main repository.

    2. Stop and remove your service.

    3. 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
      
    4. Run it.

    5. Figure out what the new port is, and observe Nagios cry.