Files
debian-vnc-xfce-g3/docker/hooks/env.rc
2024-01-29 19:43:18 -06:00

264 lines
10 KiB
Plaintext
Executable File

### 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 at line "${BASH_LINENO[0]}" in '${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
### arrays of the image tags to be deployed
declare -a _deploy_builder_tags
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 (<branch> <blend>)
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
### FEATURES_OVERRIDING_ENVV: if overriding environment variables at container startup time should be enabled
### 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:
### Warning! Anything except '0' means '1', even unset or empty.
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 influence container behaviour at startup time
### Warning! Anything except '0' means '1', even unset or empty.
if [[ "${FEATURES_OVERRIDING_ENVV}" == "0" ]] ; then FEATURES_OVERRIDING_ENVV="" ; else FEATURES_OVERRIDING_ENVV=1 ; 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 | bookworm | bookworm-chromium | bookworm-firefox)
BASETAG="12-slim"
DOCKERFILE_PATH="${_build_context}/Dockerfile.xfce.12"
;;
bullseye | bullseye-chromium | bullseye-firefox)
BASETAG="11-slim"
DOCKERFILE_PATH="${_build_context}/Dockerfile.xfce.11"
;;
* )
die "Unsupported blend '${_blend}'"
;;
esac
### set the building parameters
case "${_blend}" in
latest | latest-chromium | latest-firefox \
| bookworm | bookworm-chromium | bookworm-firefox \
| bullseye | bullseye-chromium | bullseye-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
case "${_blend}" in
latest | latest-* )
### latest -> 12
DOCKER_TAG="${_blend}"
_deploy_tags=( "latest" "12" )
_deploy_builder_tags=( "${_blend}" "${_blend/latest/12}" )
;;
bookworm | bookworm-* )
### bookworm -> 12
DOCKER_TAG="${_blend/bookworm/12}"
_deploy_tags=( "latest" "12" )
_deploy_builder_tags=( "${_blend/bookworm/latest}" "${_blend/bookworm/12}" )
;;
bullseye | bullseye-* )
### bullseye -> 11
DOCKER_TAG="${_blend/bullseye/11}"
_deploy_tags=( "11" )
_deploy_builder_tags=( "${_blend/bullseye/11}" )
;;
* )
die "Unsupported blend '${_blend}'"
;;
esac
### 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