Skip to content

jayaramn/Dockerfiles

 
 

Repository files navigation

Dockerfiles

This repository contains all base Dockerfiles for Docker that I used, published to Docker registry.

List of base images

Development

This section cover information to anyone who may contribute to this project, or wants to tweak it for its own uses.

Template-based images

For maintainability some base images are created using templates. Usually some images have multiple versions, e.g. based in major releases or OS-based images (Debian/Alpine). The Dockerfiles for different versions of an image, most of the time, are basically the same. Most common variables are product and dependency versions. Thus, it is really error prone manually modify many similar files. For those cases docker-template is used.

Docker-template is a utility tool written in Ruby that allows writing Dockerfiles using ERB templates. It also uses a opts.yml file to describe all variables for substitution. It is meant for deploying images right from templates, without saving it. Therefore, it usually does not keep generated Dockerfiles. We do keep these generated files, so we wrapped it up with a update-dockerfile.sh script. The script uses docker-template cache and docker-template list outputs to generate and update project files.

Docker-template

As described earlier, the update-dockerfile.sh script depends on docker-template. Docker-template requires Ruby 2.1+. So, firstly you need Ruby 2.1+ up and running in your system. The update script supports calling docker template through both docker-template and bundler exec docker-template. Therefore, there is two ways of installing to have docker-template installed, once you have ruby in your system.

  • Use the Gemfile provided and install via Bundler and it should be available to you through bundler exec docker-template.
# install bundler system-wide, if not installed yet
sudo gem install bundler

# install ruby dependencies in this project (docker-template)
bundler install
  • Install through rubygems and it will be available system-wide through docker-template
sudo gem install docker-template

Important: Docker template 0.9.0+ is required. As 2016-07-27, it has not been released in rubygems. Installation through bundler, pointing to project master branch, is required to this project work. Once version 0.9.0 is released, system-wide installation through gem install will work as well.

For reference how to use docker-template visit its wiki and this 2 example projects: jekyll-docker and envygeeks-docker.

Update-dockerfile

Following the docker-template schema, templates are located into /repos/[image] directory in this repository. The /opts.yml holds configurations applied to all images, like maintainer, or used in FROM directive (docker-template limitation). Each image, repository in docker-template lingo, has the following files under /repos/[image]:

  • Dockerfile: ERB-templated dockerfile.
  • opts.yml: Image specific configurations.
  • README.md: Image README without the "Supported versions and tags" section. (extension of this project)

Example:

~/projects/andreptb-dockerfiles $ ls -lhR repos/tomcat
repos/tomcat:
total 36K
-rw-rw-r-- 1 user user 2,8K Jul 22 15:50 Dockerfile
-rw-rw-r-- 1 user user  619 Jul 22 15:50 opts.yml
-rw-rw-r-- 1 user user 3,9K Jul 22 15:50 README.md

Executing update-dockerfile.sh, it will create a /[image] directory within the repository root folder for each image inside /repos/[image]. This image folder will contain:

  • a README.md generated from /repos/[image]/README.md, inserting a section of all tags (versions) provided (with links) on its top.
  • a folder per tag in opts.yml with:
    • a symlink to the image's README.md
    • a plain Dockerfile

Example:

~/projects/andreptb-dockerfiles $ ls -lhR tomcat
tomcat:
total 40K
drwxrwxr-x 2 user user 4,0K Jul 22 15:50 6-jdk6
drwxrwxr-x 2 user user 4,0K Jul 22 15:50 6-jdk7
drwxrwxr-x 2 user user 4,0K Jul 22 15:50 7-jdk7
drwxrwxr-x 2 user user 4,0K Jul 22 15:50 7-jdk8
drwxrwxr-x 2 user user 4,0K Jul 22 15:50 8-jdk7
drwxrwxr-x 2 user user 4,0K Jul 22 15:50 8-jdk8
-rw-rw-r-- 1 user user 4,7K Jul 22 15:50 README.md

tomcat/6-jdk6:
total 16K
-rw-rw-r-- 1 user user 2,7K Jul 22 15:50 Dockerfile
lrwxrwxrwx 1 user user   12 Jul 22 15:50 README.md -> ../README.md

tomcat/6-jdk7:
total 16K
-rw-rw-r-- 1 user user 2,7K Jul 22 15:50 Dockerfile
lrwxrwxrwx 1 user user   12 Jul 22 15:50 README.md -> ../README.md

tomcat/7-jdk7:
total 16K
-rw-rw-r-- 1 user user 2,7K Jul 22 15:50 Dockerfile
lrwxrwxrwx 1 user user   12 Jul 22 15:50 README.md -> ../README.md

tomcat/7-jdk8:
total 16K
-rw-rw-r-- 1 user user 2,7K Jul 22 15:50 Dockerfile
lrwxrwxrwx 1 user user   12 Jul 22 15:50 README.md -> ../README.md

tomcat/8-jdk7:
total 16K
-rw-rw-r-- 1 user user 2,7K Jul 22 15:50 Dockerfile
lrwxrwxrwx 1 user user   12 Jul 22 15:50 README.md -> ../README.md

tomcat/8-jdk8:
total 16K
-rw-rw-r-- 1 user user 2,7K Jul 22 15:50 Dockerfile
lrwxrwxrwx 1 user user   12 Jul 22 15:50 README.md -> ../README.md

The script supports update all images or a list of given ones.

# update all images/repositories in docker-template lingo
./update-dockerfile.sh

# update only tomcat image
./update-dockerfile.sh tomcat

# update tomcat and oracle-java images
./update-dockerfile.sh tomcat oracle-java

Uses ./update-dockerfile.sh --help for usage.

About

This repository contains all base Dockerfiles for Docker that I use, and are available at Docker registry.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Shell 98.8%
  • Ruby 1.2%