From adf5015de3e0fb7aadbed4dc389bea5083ae5291 Mon Sep 17 00:00:00 2001 From: accetto <34798830+accetto@users.noreply.github.com> Date: Sat, 7 Aug 2021 09:14:39 +0200 Subject: [PATCH] Release 21.08 --- .gitignore | 3 ++ CHANGELOG.md | 10 ++++ Dockerfile | 4 +- README.md | 3 -- builder.sh | 105 ++++++++++++++++++++++++++++++++++++++ local-building-example.md | 86 +++++++++++++++++++++++++++++++ utils/example-secrets.rc | 11 ++++ 7 files changed, 217 insertions(+), 5 deletions(-) create mode 100644 builder.sh create mode 100644 local-building-example.md create mode 100644 utils/example-secrets.rc diff --git a/.gitignore b/.gitignore index 19afc0e..1afd1fc 100644 --- a/.gitignore +++ b/.gitignore @@ -13,7 +13,10 @@ .vscode .developer* +.secret* *.log +avanti* debug* scrap* +secret* TODO* diff --git a/CHANGELOG.md b/CHANGELOG.md index 69d6fb8..046c5e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,16 @@ *** +### Release 21.08 + +- Docker Hub has removed auto-builds from free plans since 2021-07-26, therefore + - **if you stay on the free plan**, then + - you can still build the images locally and then push them to Docker Hub + - pushing to Docker Hub is optional + - just follow the added file `local-building-example.md` + - you can use the helper utility `builder.sh` + - regularity of updates of images on Docker Hub cannot be guaranteed any more + ### Release 21.04 - TigerVNC from [Release Mirror on accetto/tigervnc][accetto-tigervnc-release-mirror] because **Bintray** is closing on 2021-05-01 diff --git a/Dockerfile b/Dockerfile index cd5c41c..8a8596d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ -# ./hooks/build dev -# ./hooks/test dev +# ./hooks/build latest +# ./hooks/test latest ### Example: Build and test 'dev' tag locally like ### ./hooks/build dev diff --git a/README.md b/README.md index 6cd04cc..3b7c3e1 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,6 @@ The image is regularly maintained and rebuilt. The history of notable changes is - `latest` based on `ubuntu:latest` ![badge-VERSION_STICKER_LATEST][badge-VERSION_STICKER_LATEST] - ![badge-github-commit-latest][badge-github-commit-latest] ### Ports @@ -321,5 +320,3 @@ Credit also goes to all the countless people and companies who contribute to ope [badge-VERSION_STICKER_LATEST]: https://badgen.net/badge/version%20sticker/ubuntu18.04.5/blue - -[badge-github-commit-latest]: https://images.microbadger.com/badges/commit/accetto/ubuntu-vnc-xfce.svg diff --git a/builder.sh b/builder.sh new file mode 100644 index 0000000..06b7207 --- /dev/null +++ b/builder.sh @@ -0,0 +1,105 @@ +#!/bin/bash +### @accetto, August 2021 + +docker_hub_connect() { + + if [ -n "${DOCKERHUB_USERNAME}" ] && [ -n "${DOCKERHUB_PASSWORD}" ] ; then + + echo "Logging-in on Docker Hub..." + echo "${DOCKERHUB_PASSWORD}" | docker login -u "${DOCKERHUB_USERNAME}" --password-stdin + if [ ! $? ] ; then + echo "Docker Hub login failed" + return 1 + fi + else + echo "Local pushing requires Docker Hub login." + echo "However, your environment does not provide required authentication data." + return 1 + fi + + return 0 +} + +main() { + + local tag=${1?Need tag} + local cmd=${2?Need command} + + local result + + case "${cmd}" in + + build | test ) + + ./hooks/"${cmd}" "${tag}" + ;; + + push ) + + docker_hub_connect + + if [ $? -eq 0 ] ; then + + ### push to Docker Hub + ./hooks/"${cmd}" "${tag}" + + docker logout + + else + + echo "Unable to connect to Docker hub!" + fi + ;; + + all ) + + echo + echo "------------------" + echo "--> Building image" + echo "------------------" + echo + + ./hooks/build "${tag}" + + echo + echo "---------------------------" + echo "--> Testing version sticker" + echo "---------------------------" + echo + + ### test version sticker + result=$( hooks/test "${tag}" 2>&1 | tail -n1 ) + + if [ "${result}" == '+ exit 0' ] ; then + + docker_hub_connect + + if [ $? -eq 0 ] ; then + + echo + echo "-------------------------" + echo "--> Pushing to Docker Hub" + echo "-------------------------" + echo + + hooks/push "${tag}" + + docker logout + + else + + echo "Unable to connect to Docker hub!" + fi + + else + echo "Version sticker has changed. Adjust 'env' hook and refresh README using 'util-refresh-readme.sh'. Use 'test' command for details." + fi + ;; + + *) + echo "Unknown command: ${cmd}" + ;; + esac +} + +main $@ diff --git a/local-building-example.md b/local-building-example.md new file mode 100644 index 0000000..9ecbaf1 --- /dev/null +++ b/local-building-example.md @@ -0,0 +1,86 @@ +# Local building example + +- [Local building example](#local-building-example) + - [Preparation](#preparation) + - [Building pipeline](#building-pipeline) + - [Step 1: `build`](#step-1-build) + - [Step 2: `test`](#step-2-test) + - [Step 3: `push`](#step-3-push) + - [All steps at once](#all-steps-at-once) + +Docker Hub has removed auto-building from free plans since 2021-07-26. + +This page describes how to build the image locally and optionally push it to Docker Hub. + +If you just want to build the image locally without publishing it on Docker Hub, then you can use the `one-liners` shown at the top of the Dockerfile. + +There is a helper utility `builder.sh`, which supports executing the whole building pipeline locally, including pushing the image to Docker Hub. + +## Preparation + +Open a terminal windows and change the current directory to the root of the project (where the license file is). + +There is an example secrets file in the `utils` subdirectory of the project. Copy and modify it and then source it in the terminal: + +```bash +### make a copy and then modify it +cp utils/example-secrets.rc secrets.rc + +### source the secrets +source ./secrets.rc +``` + +## Building pipeline + +The full building pipeline consists of the following four hook scripts and one utility script: + +- `build` +- `test` +- `push` +- `util-refresh-readme.sh` + +The order of executing the scripts is important. + +The commands in the following example would build and publish the image `accetto/ubuntu-vnc-xfce:latest`. + +The helper utility `builder.sh` will be used. Alternatively you can also use the hook scripts directly. + +### Step 1: `build` + +```bash +./builder.sh latest build +``` + +This command builds a new local image. + +### Step 2: `test` + +```bash +./builder.sh latest test +``` + +This command checks if the version sticker has changed. This step is optional and you can skip it if you are not interested in the version sticker value. + +Otherwise, if the version sticker has changed since the last project update, then adjust the version sticker variables in the `env` hook script and repeat the steps 1 and 2. + +Also update the `README` file using the helper utility `util-refresh-readme.sh`. + +### Step 3: `push` + +```bash +./builder.sh latest push +``` + +This command will push the new image to Docker Hub. + +Note that currently you have to update the `README` file on Docker Hub yourself. You can do it in edit mode by simple copy-and-paste from the local file, which you've already updated by the helper utility described above. + +### All steps at once + +Alternatively you can execute the whole building pipeline using the `all` command: + +```bash +./builder.sh latest all +``` + +Note that this command doesn't update the `README` file. You still have to do it yourself using the helper utility described above. diff --git a/utils/example-secrets.rc b/utils/example-secrets.rc new file mode 100644 index 0000000..428b921 --- /dev/null +++ b/utils/example-secrets.rc @@ -0,0 +1,11 @@ +### This files configures the environment (including secrets!) for the local builder utility (builder.sh). +### You should source this file yourself before using the local builder utility. +### Rename the file to "secrets.rc" (or similar) and **make sure** that the '.gitignore' and '.dockerignore' files +### contain the 'secret*' exclusion pattern! + +### Required only for publishing README on Docker Hub. +### These values can be also provided or overriden through the utility input arguments. +### !!! REAL SECRETS !!! +### warning! this credentials are valid for all Docker Hub repositories of the same owner! +export DOCKERHUB_USERNAME="xxxxxx" +export DOCKERHUB_PASSWORD="xxxxxx"