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
```
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
Built Distribution
File details
Details for the file docker-ci-deploy-0.1.2.tar.gz
.
File metadata
- Download URL: docker-ci-deploy-0.1.2.tar.gz
- Upload date:
- Size: 5.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d526d5bc803e3f491aff501c34bf1c3e70c5a82cb8b3d4cb04c6ed92df304f66 |
|
MD5 | 863297d6a5184a7ebdf56b61e3b9f26e |
|
BLAKE2b-256 | 0461894e7a5f7148692fbcb82e3c136e23a9bad6382ac815d0737e266f6ad69a |
File details
Details for the file docker_ci_deploy-0.1.2-py2.py3-none-any.whl
.
File metadata
- Download URL: docker_ci_deploy-0.1.2-py2.py3-none-any.whl
- Upload date:
- Size: 7.0 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1759ac72ad6c1ff367418fed2f96bbb8fd3a54d80742637affe8bf54ee679181 |
|
MD5 | f61577fd3570162c8ba922db181e6baf |
|
BLAKE2b-256 | c1f0521710e2c4004d1d6b501a0e269ba758f25dd325a2deaa9eb69c81d257ef |