ReleaseProcess-create-docker-image.md (zonemaster-2021.2) | : | ReleaseProcess-create-docker-image.md (zonemaster-2021.2.1) | ||
---|---|---|---|---|
Release Process - Create Docker Image | Release Process - Create Docker Image | |||
===================================== | ===================================== | |||
## Table of contents | ## Table of contents | |||
* [1. Overview](#1-overview) | * [1. Overview](#1-overview) | |||
* [2. Prerequsite](#2-prerequsite) | * [2. Prerequsite](#2-prerequsite) | |||
* [3. Create Docker images](#3-create-docker-images) | * [3. Create Docker images](#3-create-docker-images) | |||
* [4. Upload images to Docker Hub](#4-upload-images-to-docker-hub) | * [4. Upload images to Docker Hub](#4-upload-images-to-docker-hub) | |||
* [5. Image sanity checks][sanity checks] | * [5. Image sanity checks][sanity checks] | |||
* [6. Handy Docker commands](#6-handy-docker-commands) | * [6. Handy Docker commands][Handy Docker commands] | |||
## 1. Overview | ## 1. Overview | |||
This document covers two stages in the release processes: | This document covers two stages in the release processes: | |||
1. Creating Docker images for testing. | 1. Creating Docker images for testing. | |||
2. Creating Docker image for publishing on Docker Hub | 2. Creating Docker image for publishing on Docker Hub | |||
Presently only Zonemaster-CLI is published, and therefore only Zonemaster-LDNS, | Presently only Zonemaster-CLI is published, and therefore only Zonemaster-LDNS, | |||
Zonemaster-Engine and Zonemaster-CLI are covered here. | Zonemaster-Engine and Zonemaster-CLI are covered here. | |||
skipping to change at line 33 | skipping to change at line 33 | |||
## 2. Prerequsite | ## 2. Prerequsite | |||
The steps in this documents are assumed to be executed on a computer installed | The steps in this documents are assumed to be executed on a computer installed | |||
as an [Ubuntu Build Environment] computer. It could work on another OS as long | as an [Ubuntu Build Environment] computer. It could work on another OS as long | |||
as the same support is available. | as the same support is available. | |||
All commands in this instruction are assumed to be executed from the one and the | All commands in this instruction are assumed to be executed from the one and the | |||
same directory. If you run `cd`, then you have to run `cd` back to the start | same directory. If you run `cd`, then you have to run `cd` back to the start | |||
directory. | directory. | |||
The Docker environment is assumed to be clean. Consider running the following | ||||
commands to clean up before proceeding (see section "[Handy Docker commands]"): | ||||
```sh | ||||
[ "$(docker ps -a -q)" != '' ] && docker rm -f $(docker ps -a -q) | ||||
``` | ||||
```sh | ||||
[ "$(docker image ls -q)" != '' ] && docker image prune -a | ||||
``` | ||||
## 3. Create Docker images | ## 3. Create Docker images | |||
Clone the three repositories: | Clone the three repositories: | |||
```sh | ```sh | |||
git clone https://github.com/zonemaster/zonemaster-ldns | git clone https://github.com/zonemaster/zonemaster-ldns | |||
git clone https://github.com/zonemaster/zonemaster-engine | git clone https://github.com/zonemaster/zonemaster-engine | |||
git clone https://github.com/zonemaster/zonemaster-cli | git clone https://github.com/zonemaster/zonemaster-cli | |||
``` | ``` | |||
skipping to change at line 65 | skipping to change at line 74 | |||
```sh | ```sh | |||
git -C zonemaster-ldns checkout origin/master | git -C zonemaster-ldns checkout origin/master | |||
git -C zonemaster-engine checkout origin/master | git -C zonemaster-engine checkout origin/master | |||
git -C zonemaster-cli checkout origin/master | git -C zonemaster-cli checkout origin/master | |||
``` | ``` | |||
Create `Makefile` in all three repositories | Create `Makefile` in all three repositories | |||
```sh | ```sh | |||
(cd zonemaster-ldns; git clean -dfx; perl Makefile.PL) | (cd zonemaster-ldns; git clean -dfx; git reset --hard; perl Makefile.PL) | |||
``` | ``` | |||
```sh | ```sh | |||
(cd zonemaster-engine; git clean -dfx; perl Makefile.PL) | (cd zonemaster-engine; git clean -dfx; git reset --hard; perl Makefile.PL) | |||
``` | ``` | |||
```sh | ```sh | |||
(cd zonemaster-cli; git clean -dfx; perl Makefile.PL) | (cd zonemaster-cli; git clean -dfx; git reset --hard; perl Makefile.PL) | |||
``` | ``` | |||
Create an image for each repository. That image will be tagged "local". The | Create an image for each repository. That image will be tagged "local". The | |||
images must be created in order since there is a dependency on the previous | images must be created in order since there is a dependency on the previous | |||
image in each step. | image in each step. | |||
```sh | ```sh | |||
make -C zonemaster-ldns all dist docker-build | make -C zonemaster-ldns all dist docker-build | |||
``` | ``` | |||
```sh | ```sh | |||
make -C zonemaster-engine all docker-build | make -C zonemaster-engine all dist docker-build | |||
``` | ``` | |||
```sh | ```sh | |||
make -C zonemaster-cli all docker-build | make -C zonemaster-cli all dist docker-build | |||
``` | ``` | |||
For the Zonemaster-CLI image, add a version tag and a tag "latest". | For the Zonemaster-CLI image, add a version tag and a tag "latest". | |||
* Add version tag: | * Add version tag: | |||
```sh | ```sh | |||
make -C zonemaster-cli docker-tag-version | make -C zonemaster-cli docker-tag-version | |||
``` | ``` | |||
* Add tag "latest": | * Add tag "latest": | |||
```sh | ```sh | |||
make -C zonemaster-cli docker-tag-latest | make -C zonemaster-cli docker-tag-latest | |||
``` | ``` | |||
All the created images can now be listed. Also consider doing [sanity checks] to | All the created images can now be listed. Also consider doing [sanity checks] to | |||
verify that all images work. List images: | verify that all images work. Images without tag are temporary images without | |||
further use. List images: | ||||
```sh | ```sh | |||
docker images | docker images | |||
``` | ``` | |||
## 4. Upload images to Docker Hub | ## 4. Upload images to Docker Hub | |||
To upload an image to the Zonemaster Docker Hub organization you have to have | To upload an image to the Zonemaster Docker Hub organization you have to have | |||
a Docker Hub account and the authorization to upload images. | a Docker Hub account and the authorization to upload images. | |||
```sh | ```sh | |||
docker login -u $DOCKERUSER | docker login | |||
``` | ``` | |||
The same image is pushed twice with different tags. Verify in the listing | The same image is pushed twice with different tags. Verify in the listing | |||
above that they have the same ID. | above that they have the same ID. | |||
* Push latest. | * Push latest. | |||
```sh | ```sh | |||
docker push zonemaster/cli:latest | docker push zonemaster/cli:latest | |||
``` | ``` | |||
* Set correct version (see listing) and push image with version tag: | * Set correct version (see listing above) and push image with version tag: | |||
```sh | ```sh | |||
docker push zonemaster/cli:v0.0.0 | docker push zonemaster/cli:v0.0.0 | |||
``` | ``` | |||
## 5. Image sanity checks | ## 5. Image sanity checks | |||
Zonemaster-LDNS: | Zonemaster-LDNS: | |||
```sh | ```sh | |||
docker run --rm zonemaster/ldns:local perl -MZonemaster::LDNS -E 'say Zonemaster ::LDNS->new("9.9.9.9")->query("zonemaster.net")->string' | docker run --rm zonemaster/ldns:local perl -MZonemaster::LDNS -E 'say Zonemaster ::LDNS->new("9.9.9.9")->query("zonemaster.net")->string' | |||
skipping to change at line 192 | skipping to change at line 202 | |||
```sh | ```sh | |||
docker save -o docker-zonemaster-cli.tar zonemaster/engine | docker save -o docker-zonemaster-cli.tar zonemaster/engine | |||
``` | ``` | |||
Load an image from a tar file | Load an image from a tar file | |||
```sh | ```sh | |||
docker load -i docker-zonemaster-cli.tar | docker load -i docker-zonemaster-cli.tar | |||
``` | ``` | |||
[Ubuntu Build Environment]: ../distrib-testing/Ubuntu-build-enviro nment.md | [Ubuntu Build Environment]: ../distrib-testing/Ubuntu-build-enviro nment.md | |||
[sanity checks]: #5-image-sanity-checks | [Sanity checks]: #5-image-sanity-checks | |||
[Handy Docker commands]: #6-handy-docker-commands | ||||
End of changes. 11 change blocks. | ||||
9 lines changed or deleted | 19 lines changed or added |