-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
217 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,10 @@ | |
|
||
.vscode | ||
.developer* | ||
.secret* | ||
*.log | ||
avanti* | ||
debug* | ||
scrap* | ||
secret* | ||
TODO* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 $@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" |