Skip to main content

The right way to build, tag and ship shared Docker containers.

Project description

FORK

While https://github.com/6si/shipwright will be kept up-to-date. I only have access to the dockhand name on PyPI.

Shipwright builds shared Docker images within a git repository in the right order and publishes them tagged with git’s revision/branch information so you’ll never loose track of an image’s origin.

It’s the perfect tool for building and publishing your images to places like Docker Hub or your own private registry. Have a look at our motivation to see why we built it and the pain points it solves for you.

Installation

Shipwright is a simple python script you can install with pip

$ pip install shipwright

Quickstart

Once installed, simply change to a project of yours that contains multiple Dockerfiles and is in git.

Add a json formatted file named .shipwright.json to the root directory of your project. At minimum it should contain the version number of your Shipwright config and a namespace which is either your docker hub user name or the URL to your private repository.

1.0 is the current version for the config.

{
  "version": 1.0,
  "namespace": "[your docker hub name or private repository]"
}

Additionally your config file can map directory names to alternative docker repositories. For example here is a .shipwright.json for the docker hub user shipwright that also maps the root of the git repository to the docker image shipwright/shared and the /foo directory to shipwright/awesome_sauce.

{
  "version": 1.0,

  "namespace": "shipwright",
  "names": {
    "/": "shipwright/shared",
    "/foo": "shipwright/awesome_sauce"
}

Now you can build all the docker images in the git repo by simply changing to any directory under your git repo and running:

$ shipwright

This will recurse through all the directories, looking for ones that contain a Dockerfile. Shipwright will build these Dockerfiles in order and by default tag them with <namespace>/<dirname>:<git commit> along with <namespace>/<dirname>:<git branch> and <namespace>/<dirname>:latest

Working example

We have a sample shipwright project you can use if you want to try this out right away.

$ git clone https://github.com/6si/shipwright-sample.git
$ cd shipwright-sample
$ shipwright

NOTE: you can use any username you’d like while building locally. In the above example we use ``shipwright``. Nothing is published unless you use the ``push`` command. For your own projects, substitute ``shipwright`` in the above example with your (or your organizations) official docker hub username or private repository.

Notice that if you run the shipwright a second time it will return immediately without doing anything. Shipwright is smart enough to know nothing has changed.

Shipwright really shines when you switch git branches.

$ git checkout new_feature
$ shipwright

Notice that shipwright only rebuilt the shared library and service1, ignoring the other projects because they have a common git ancestry. Running docker images however shows that all the images in the git repository have been tagged with the latest git revision, branch and latest.

In fact, as Shipwright builds containers it rewrites the Dockerfiles so that they require the base images with tags from the current git revision. This ensures that the entire build is deterministic and reproducible.

Building

By default, if you run shipwright with no arguments, it will build all Dockerfiles in your git repo. You can specify one or more specifiers to select fewer images to build. For example you can build a single images and its dependencies by simply specifying its name on the command line.

$ shipwright <namespace>/some_image

Run `shipwright –help’ for more examples of specifiers and their uses.

Publishing

With one command Shipwright can build your images and push them to a remote repository.

$ shipwright push

If you like you can just push your latest images without building.

$ shipwright push --no-build

The same specifiers for building also work with push. You might use this to build an entire tree in one step then push a specific image like so.

$ shipwright build
$ shipwright push -e <namespace>/public_image

0.4.0 (2016-06-13)

  • Isolate all git functionality, so as to create pluggable Source Control wrappers.

  • More efficient required build detection. (Issue #63)

  • Isolate all zipper usage, vendor zipper library.

0.2.2 (2015-01-07)

  • Fix bug missing tls when communicating with docker over a unix socket.

0.2.1 (2015-01-01)

  • Force tag to support docker 1.4.1

  • Requries docker-py >= 0.6

  • Added assert_hostname as an option to .shipwright.json

  • Added command line option --x-assert-hostname to disable hostname checking when TLS is used. Useful for boot2docker

0.2.0 (2014-12-31)

  • Added shipwright push and shipwright purge

  • Added support for specifiers -u, -d, -e and -x

0.1.0 (2014-09-10)

  • Build and tag containers

  • Moved config to .shipwright.json

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dockhand-0.4.0.tar.gz (17.9 kB view details)

Uploaded Source

Built Distribution

dockhand-0.4.0-py2.py3-none-any.whl (21.5 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file dockhand-0.4.0.tar.gz.

File metadata

  • Download URL: dockhand-0.4.0.tar.gz
  • Upload date:
  • Size: 17.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for dockhand-0.4.0.tar.gz
Algorithm Hash digest
SHA256 76bbd67ad2e6efd53c5c84cc37962d9b51ff1b96e0f490058605c417ec40cd08
MD5 ec97d2139ac5f7dc37b719d0a09b19ea
BLAKE2b-256 6188d5e4bbb102540b119f4fd0f72cfb6d2238cba268d0453557864d0b187909

See more details on using hashes here.

File details

Details for the file dockhand-0.4.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for dockhand-0.4.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 2b394084d1820fb811132ef5c37c87f343886e53884b846bb112f1e8a4b518c5
MD5 d01f76dfb5337f6063b824a66ba8e649
BLAKE2b-256 eba7da1b81c7dba0222c60fa0747ca4ebc773285636337aea70644d00a2c180b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page