Skip to main content

Python script to help push Docker images to a registry using CI services

Project description

# docker-ci-deploy
Python script to help push Docker images to a registry using CI services

## Installation
```
pip install docker-ci-deploy
```

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, login to a registry, and push the tags to the registry, depending on what arguments are passed to it.

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

#### Logging in
On a CI service you are unlikely to be logged in to the registry. You can login using the `--login` parameter, which takes an argument of the form `<username>:<password>`.
```
docker-ci-deploy --login 'janedoe:pa$$word' my-image:latest
```
The script will then login before pushing the image.

#### Tagging
```
docker-ci-deploy --login 'janedoe:pa$$word' \
--tag alpine --tag $(git rev-parse --short HEAD) my-image:latest

```
This will result in the tags `my-image:alpine` and `my-image:eea981f` (for example) being created and pushed (**Note:** the original tag `my-image:latest` is _not_ pushed).

#### Custom registry
```
docker-ci-deploy --login 'janedoe:pa$$word' \
--tag alpine --tag $(git rev-parse --short HEAD) \
--registry my-registry.example.com:5000 \
my-image:latest
```
This will result in the tags `my-registry.example.com:5000/my-image:alpine` and `my-registry.example.com:5000/my-image:eea981f` being created and pushed. A login request will be made to `my-registry.example.com:5000`.

#### 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: <encrypted> # 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 .

deploy:
provider: script
script: docker-ci-deploy --tag $(git rev-parse --short HEAD) --tag latest --login "$DOCKER_USER:$DOCKER_PASS" janedoe/my-image
```

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

docker-ci-deploy-0.1.3.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

docker_ci_deploy-0.1.3-py2.py3-none-any.whl (7.4 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file docker-ci-deploy-0.1.3.tar.gz.

File metadata

File hashes

Hashes for docker-ci-deploy-0.1.3.tar.gz
Algorithm Hash digest
SHA256 bafa74b03e853edbcdcd48e96b34a1ad13be5cda09aa98ab4e5141609f1ee734
MD5 d96a2c2c7bcc18667fea2e1e6e11ca21
BLAKE2b-256 6e1f4926f9be4b20a9663a94b2237cda6a7d1a81f21c7bd1a1437ec29bd1fd04

See more details on using hashes here.

File details

Details for the file docker_ci_deploy-0.1.3-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for docker_ci_deploy-0.1.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 f32cc3af00adfa35dc0b7b3e8cdc837a14087ee0718a00b7a67632d6125c52ba
MD5 4f7c87eb3e2fb2c5bf9e15cde13325cf
BLAKE2b-256 30695db19cf7b3814894863d58cfc99b2ab30e9026b36a34bb75a767fa6c9dc0

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