### All variables in capitals can be set also from the same name environment variables. die() { local message="${1:-(unknown)}" local -i code=${2:-1} local place="${3:-$0}" echo -e "EXITING '${place}' with code ${code}: ${message}" >&2 exit ${code} } ### build context is the path to the Dockerfile ### it is expected that '_mydir' is already set by the calling script declare _build_context="$(dirname ${_mydir})" ### be careful with moving this block ### supporting development and testing if [[ -f "${_build_context}/hooks/secrets.rc" ]] ; then source "${_build_context}/hooks/secrets.rc" fi ### Docker Hub: GitHub source branch to use ### local: virtual source branch (technically always the current git branch) declare _branch="${SOURCE_BRANCH:-$1}" ### which image variation to build (feature blend) declare _blend="${DOCKER_TAG:-$2}" ### owner of the builder and deployment repositories must be the same declare _owner="${REPO_OWNER_NAME:?Need repo owner name}" ### utility scripts # declare _script_release_of="release_of" # currently unused ### using this repository name will prohibit the publishing declare _prohibited_repo_name="void" ### Originally (generation G3) this was the name of the Docker Hub repository ### where the images have been built (the builder repository). ### It has been initialized by the environment on the Docker Hub. ### Since the generation G3v2, the builder repository is optional, because the images ### are built outside the Docker Hub. However, it can be used as a secondary ### deployment repository, even if it still be referenced as a 'builder repository'. ### The images in this secondary deployment repository will be distinguished by their tags. ### Publishing to the builder repository is controlled by the variable 'FORCE_PUBLISHING_BUILDER_REPO'. ### Note that using the prohibited repository name ('void' by default) will prohibit the publishing. DOCKER_REPO="${_owner}/${BUILDER_REPO:?Need builder repo name}" declare _deploy_repo ### array of the image tags to be deployed declare -a _deploy_tags declare _deploytag ### relative path to the readme file resources (relative to the project root) declare _readme_context ### examples # VERSION_STICKER_PREFIX=${VERSION_STICKER_SUFFIX:-"BETA-"} # VERSION_STICKER_SUFFIX=${VERSION_STICKER_SUFFIX:-"-BETA"} ### be careful with moving this statement ### remove the first two command line arguments ( ) if [[ $# -ge 2 ]] ; then shift 2 ; fi ### Features can be enabled or disabled by setting the related variables. ### Setting it to "0" disables the feature. ### Setting it to "1" enforces the feature. ### Anything else, including null and empty string, does not change the feature's default value. ### NOTE: They are also other feature environment variables that are set directly in the Dockerfile. ### FEATURES_BUILD_SLIM: if to add '--no-install-recommends' to 'apt-get install' ### FEATURES_NOVNC: if 'noVNC' and 'websockify' should be included ### FEATURES_SCREENSHOOTING: if 'xfce4-screenshooter' and 'ristretto' should be included ### FEATURES_THUMBNAILING: if 'tumbler' should be included ### Remark: There are also 'FEATURES_*' variables that are always set, e.g. 'FEATURES_VERSION_STICKER=1'. ### These features influence the content of almost all stages: if [[ "${FEATURES_BUILD_SLIM}" == "0" ]] ; then FEATURES_BUILD_SLIM="" ; else FEATURES_BUILD_SLIM=1 ; fi ### These features influence the content of the related stages: if [[ "${FEATURES_SCREENSHOOTING}" == "1" ]] ; then FEATURES_SCREENSHOOTING=1 ; else FEATURES_SCREENSHOOTING="" ; fi if [[ "${FEATURES_THUMBNAILING}" == "1" ]] ; then FEATURES_THUMBNAILING=1 ; else FEATURES_THUMBNAILING="" ; fi ### These features influence the building graph: if [[ "${FEATURES_CHROMIUM}" == "1" ]] ; then FEATURES_CHROMIUM=1 ; else FEATURES_CHROMIUM="" ; fi if [[ "${FEATURES_FIREFOX}" == "1" ]] ; then FEATURES_FIREFOX=1 ; else FEATURES_FIREFOX="" ; fi ### These features are always enabled and cannot be disabled via environment variables FEATURES_VNC=1 ### These features are enabled by default but can be disabled via environment variables (see below) ### however, they can be disabled via environment variables (see below) # if [[ "${FEATURES_NOVNC}" == "1" ]] ; then FEATURES_NOVNC=1 ; else FEATURES_NOVNC="" ; fi # if [[ "${FEATURES_FIREFOX_PLUS}" == "1" ]] ; then FEATURES_FIREFOX_PLUS=1 ; else FEATURES_FIREFOX_PLUS="" ; fi ### The reason for this 'case' is to support some special branches/builds if required. case "${_branch}" in ### default (master), developer (dev, dev-*) and release (v*) builds master | dev | dev-* | v* ) ### fallback to defaults if not provided BASEIMAGE="${BASEIMAGE:-debian}" ### hardcoded settings TIGERVNC_VERSION="1.13.1" TIGERVNC_DISTRO="x86_64" NOVNC_VERSION="1.4.0" WEBSOCKIFY_VERSION="0.11.0" ### ---------------------------- ### debian-vnc-xfce-g3 ### debian-vnc-xfce-firefox-g3 ### debian-vnc-xfce-chromium-g3 ### ---------------------------- ### choose the Dockerfile case "${_blend}" in latest | latest-chromium | latest-firefox) BASETAG="11-slim" DOCKERFILE_PATH="${_build_context}/Dockerfile.xfce" ;; * ) die "Unsupported blend '${_blend}'" ;; esac ### set the building parameters case "${_blend}" in latest | latest-chromium | latest-firefox ) ### this feature is enabled by default ### however, it can be disabled via environment variables (export FEATURES_NOVNC=0) if [[ "${FEATURES_NOVNC}" == "0" ]] ; then FEATURES_NOVNC="" else FEATURES_NOVNC="1" fi ### images with chromium if [[ "${_blend}" =~ chromium ]] ; then FEATURES_CHROMIUM=1 _deploy_repo="${_owner}/${DEPLOYMENT_REPO_CHROMIUM}" _readme_context="docker/xfce-chromium" else FEATURES_CHROMIUM="" fi if [[ "${_blend}" =~ firefox ]] ; then FEATURES_FIREFOX=1 ### this feature is enabled by default ### however, it can be disabled via environment variables (export FEATURES_FIREFOX_PLUS=0) if [[ "${FEATURES_FIREFOX_PLUS}" == "0" ]] ; then FEATURES_FIREFOX_PLUS="" else FEATURES_FIREFOX_PLUS="1" fi _deploy_repo="${_owner}/${DEPLOYMENT_REPO_FIREFOX}" _readme_context="docker/xfce-firefox" else FEATURES_FIREFOX="" FEATURES_FIREFOX_PLUS="" fi ### base images if [[ ! "${_blend}" =~ chromium|firefox ]] ; then ### be sure to reset these features FEATURES_CHROMIUM="" FEATURES_FIREFOX="" FEATURES_FIREFOX_PLUS="" _deploy_repo="${_owner}/${DEPLOYMENT_REPO}" _readme_context="docker/xfce" fi ### normalize deployment tags DOCKER_TAG="${_blend}" _deploy_tags=( "latest" ) ### add optional suffixes to deployment tags if [[ "${FEATURES_FIREFOX}" == "1" && -z "${FEATURES_FIREFOX_PLUS}" ]] ; then DOCKER_TAG="${DOCKER_TAG}-default" for i in "${!_deploy_tags[@]}" ; do _deploy_tags[$i]="${_deploy_tags[$i]}-default" done fi if [[ -z "${FEATURES_NOVNC}" ]] ; then DOCKER_TAG="${DOCKER_TAG}-vnc" for i in "${!_deploy_tags[@]}" ; do _deploy_tags[$i]="${_deploy_tags[$i]}-vnc" done fi ;; * ) die "Unsupported blend '${_blend}'" ;; esac ;; * ) die "Unsupported branch '${_branch}'" ;; esac