Python script to help push Docker images to a registry using CI services
Project description
docker-ci-deploy
================
`|PyPI| <https://pypi.python.org/pypi/docker-ci-deploy>`_ `|Build
Status| <https://travis-ci.org/praekeltfoundation/docker-ci-deploy>`_
`|codecov| <https://codecov.io/gh/praekeltfoundation/docker-ci-deploy>`_
NOTE: The ``-l``/``--login`` parameter (and associated
``-d``/``--debug`` parameter) has been removed in version 0.3.0. Use
a manual ``docker login`` command in the ``before_deploy`` section
of your Travis file (or equivalent) to log in.
A command-line tool to help generate tags and push Docker images to a
registry. Simplifies deployment of Docker images from CI services such
as Travis CI.
In a single command, ``docker-ci-deploy`` can: \* Change the tags on
images \* Add version information to image tags \* Add registry
addresses to image tags \* Push tags to a registry
The best way to try out ``docker-ci-deploy`` is to give it a spin with
the ``--dry-run`` flag and observe all the ``docker`` commands that it
*would* invoke: \`\`\` > dcd -V 3.6.0 -S -L -r registry:5000 --dry-run
alpine-python
docker tag alpine-python registry:5000/alpine-python:3.6.0 docker tag
alpine-python registry:5000/alpine-python:3.6 docker tag alpine-python
registry:5000/alpine-python:3 docker tag alpine-python
registry:5000/alpine-python:latest docker push
registry:5000/alpine-python:3.6.0 docker push
registry:5000/alpine-python:3.6 docker push
registry:5000/alpine-python:3 docker push
registry:5000/alpine-python:latest \`\`\`
Use the ``-h``/``--help`` option to see all available options.
Installation
------------
::
pip install docker-ci-deploy==0.2.0
The script is self-contained and has no dependencies. It can be run by
simply executing the `main file <docker-ci-deploy/__main__.py>`_.
Usage
-----
The script can tag an existing image and push the new tags to a
registry.
There is one required argument: the image to push.
Pushing an image
^^^^^^^^^^^^^^^^
::
docker-ci-deploy my-image:latest
This will simply push the image ``my-image:latest`` to the default
registry (https://hub.docker.com).
Tagging
^^^^^^^
\`\`\` docker-ci-deploy --tag alpine --tag ``. This means that version strings with some
text in them are also supported. For example, a tag such as
``8.7.1-jessie`` will produce the tags/tag prefixes ``8.7.1-jessie``,
``8.7.1``, ``8.7``, and ``8``.
An optional "precision" value can be set using the
``--semver-precision`` option. This sets the minimum precision of the
generated versions. For example, by passing
``--version 1.2.3 --version-semver --semver-precision 2``, the versions
``1.2.3`` and ``1.2`` are generated but *not* ``1``.
Note that this will **not** tag a version ``0`` unless the
``--semver-zero`` option is also used.
This can be used in combination with ``--version-latest``.
NOTE: The ``--version-semver`` option used to be known as
``--tag-version``. This old option name will continue working for
the current release but will be removed soon.
Custom registry
^^^^^^^^^^^^^^^
``docker-ci-deploy \ --tag alpine --tag (git rev-parse --short HEAD) my-image my-other-image``
This will result in the tags ``my-image:eea981f`` and
``my-other-image:eea981f`` being created and pushed.
Debugging
^^^^^^^^^
Use the ``--dry-run`` and ``--verbose`` parameters to see what the
script will do before you use it. For more help try
``docker-ci-deploy --help``.
Travis CI
---------
The script could be used in any CI service that provides access to the
standard Docker CLI but was developed with Travis in mind.
For Travis CI this config should get you started pushing images to
Docker Hub: \`\`\`yaml sudo: required services: - docker language:
python env: global: - DOCKER\_USER=janedoe - secret: #
DOCKER\_PASS=pa$$word
before\_install: - sudo apt-get update - sudo apt-get install -o
Dpkg::Options::="--force-confold" -y docker-engine - pip install
docker-ci-deploy
script: - docker build -t janedoe/my-image .
before\_deploy: - docker login -u ":math:`DOCKER_USER" -p "`\ DOCKER\_PASS"
deploy: provider: script script: docker-ci-deploy --tag $(git rev-parse
--short HEAD) --tag latest janedoe/my-image \`\`\`
.. |PyPI| image:: https://img.shields.io/pypi/v/docker-ci-deploy.svg
.. |Build
Status| image:: https://travis-ci.org/praekeltfoundation/docker-ci-deploy.svg?branch=develop
.. |codecov| image:: https://codecov.io/gh/praekeltfoundation/docker-ci-deploy/branch/develop/graph/badge.svg
================
`|PyPI| <https://pypi.python.org/pypi/docker-ci-deploy>`_ `|Build
Status| <https://travis-ci.org/praekeltfoundation/docker-ci-deploy>`_
`|codecov| <https://codecov.io/gh/praekeltfoundation/docker-ci-deploy>`_
NOTE: The ``-l``/``--login`` parameter (and associated
``-d``/``--debug`` parameter) has been removed in version 0.3.0. Use
a manual ``docker login`` command in the ``before_deploy`` section
of your Travis file (or equivalent) to log in.
A command-line tool to help generate tags and push Docker images to a
registry. Simplifies deployment of Docker images from CI services such
as Travis CI.
In a single command, ``docker-ci-deploy`` can: \* Change the tags on
images \* Add version information to image tags \* Add registry
addresses to image tags \* Push tags to a registry
The best way to try out ``docker-ci-deploy`` is to give it a spin with
the ``--dry-run`` flag and observe all the ``docker`` commands that it
*would* invoke: \`\`\` >
alpine-python
docker tag alpine-python registry:5000/alpine-python:3.6.0 docker tag
alpine-python registry:5000/alpine-python:3.6 docker tag alpine-python
registry:5000/alpine-python:3 docker tag alpine-python
registry:5000/alpine-python:latest docker push
registry:5000/alpine-python:3.6.0 docker push
registry:5000/alpine-python:3.6 docker push
registry:5000/alpine-python:3 docker push
registry:5000/alpine-python:latest \`\`\`
Use the ``-h``/``--help`` option to see all available options.
Installation
------------
::
pip install docker-ci-deploy==0.2.0
The script is self-contained and has no dependencies. It can be run by
simply executing the `main file <docker-ci-deploy/__main__.py>`_.
Usage
-----
The script can tag an existing image and push the new tags to a
registry.
There is one required argument: the image to push.
Pushing an image
^^^^^^^^^^^^^^^^
::
docker-ci-deploy my-image:latest
This will simply push the image ``my-image:latest`` to the default
registry (https://hub.docker.com).
Tagging
^^^^^^^
\`\`\` docker-ci-deploy --tag alpine --tag
text in them are also supported. For example, a tag such as
``8.7.1-jessie`` will produce the tags/tag prefixes ``8.7.1-jessie``,
``8.7.1``, ``8.7``, and ``8``.
An optional "precision" value can be set using the
``--semver-precision`` option. This sets the minimum precision of the
generated versions. For example, by passing
``--version 1.2.3 --version-semver --semver-precision 2``, the versions
``1.2.3`` and ``1.2`` are generated but *not* ``1``.
Note that this will **not** tag a version ``0`` unless the
``--semver-zero`` option is also used.
This can be used in combination with ``--version-latest``.
NOTE: The ``--version-semver`` option used to be known as
``--tag-version``. This old option name will continue working for
the current release but will be removed soon.
Custom registry
^^^^^^^^^^^^^^^
``docker-ci-deploy \ --tag alpine --tag
This will result in the tags ``my-image:eea981f`` and
``my-other-image:eea981f`` being created and pushed.
Debugging
^^^^^^^^^
Use the ``--dry-run`` and ``--verbose`` parameters to see what the
script will do before you use it. For more help try
``docker-ci-deploy --help``.
Travis CI
---------
The script could be used in any CI service that provides access to the
standard Docker CLI but was developed with Travis in mind.
For Travis CI this config should get you started pushing images to
Docker Hub: \`\`\`yaml sudo: required services: - docker language:
python env: global: - DOCKER\_USER=janedoe - secret: #
DOCKER\_PASS=pa$$word
before\_install: - sudo apt-get update - sudo apt-get install -o
Dpkg::Options::="--force-confold" -y docker-engine - pip install
docker-ci-deploy
script: - docker build -t janedoe/my-image .
before\_deploy: - docker login -u ":math:`DOCKER_USER" -p "`\ DOCKER\_PASS"
deploy: provider: script script: docker-ci-deploy --tag $(git rev-parse
--short HEAD) --tag latest janedoe/my-image \`\`\`
.. |PyPI| image:: https://img.shields.io/pypi/v/docker-ci-deploy.svg
.. |Build
Status| image:: https://travis-ci.org/praekeltfoundation/docker-ci-deploy.svg?branch=develop
.. |codecov| image:: https://codecov.io/gh/praekeltfoundation/docker-ci-deploy/branch/develop/graph/badge.svg