Coder Social home page Coder Social logo

docker-puppet-demo's Introduction

Demo for building docker images with puppet and packer

The aim of this demo is to show how building docker images from puppet code can be achieved in a simple and reliable way.

What it does

The demo uses some simple puppet code to provision the docker images to run a simple demo php application.

The Makefile just wraps some longer commands to make them easier to use.

The bin/packer.sh script uses docker-compose to start a puppet server and puppetdb (as dependencies in docker-compose.yml) and then runs packer in a docker container.

Packer starts a docker container from an image defined in the template and vars file and for the base image installs puppet into the container. Afterwards, puppet is run against the puppet server started earlier. The puppet ssl certificates need to be removed as the containers have different hostnames on every run. After packer finished running puppet an image is created from the container.

Requirements

  • docker
  • docker-compose
  • r10k (because it doesn't run well in docker)

Running the demo

  1. Install required puppet modules
    r10k puppetfile install
  2. Create the base docker image containing puppet and basic adjustments
    make base
  3. Create the other docker images which depend on the base image
    make apache-base php-fpm mariadb-base
  4. Create the docker images for the demo
    make demo-app1-apache demo-db
  5. Run the demo application
    cd demo-app
    docker-compose up
    curl localhost:8080

Future possible improvements

Running tests on the created image

After tagging the image a shell-local provisioner step can be added to run a testsuite using serverspec. After successful test run the image can be tagged latest and pushed to the registry. This is currently broken as of packer 1.6.4 but should be fixed in packer 1.6.5.

Installing puppet in a temporary volume instead of in the image

It should be possible to mount a volume to /opt/puppetlabs into which puppet is installed so the puppet executables are not part of the finished image.

docker-puppet-demo's People

Contributors

liwo avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.