61 lines
1.8 KiB
Bash
Executable file
61 lines
1.8 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
# The architecture - possible values: arm (default), x86, x86_64
|
|
arch="${arch:-arm}";
|
|
|
|
download_url="https://github.com/minetest-mapserver/mapserver/releases/latest/download/mapserver-linux-${arch}";
|
|
|
|
# The registry to push to
|
|
DOCKER_REGISTRY="${DOCKER_REGISTRY:-registry.service.mooncarrot.space:5000/}";
|
|
if [[ "${DOCKER_REGISTRY}" == "hub" ]]; then DOCKER_REGISTRY=""; fi
|
|
|
|
###############################################################################
|
|
|
|
# Make sure the current directory is the location of this script to simplify matters
|
|
cd "$(dirname "$(readlink -f "$0")")" || { echo "[minetest-mapserver] Error: Failed to cd"; exit 1; };
|
|
|
|
temp_dir="$(mktemp --tmpdir -d "minetest-mapserver-XXXXXXX")";
|
|
on_exit() {
|
|
log_msg "Cleaning up";
|
|
rm -rf "${temp_dir}";
|
|
}
|
|
trap on_exit EXIT;
|
|
|
|
# Ref https://stackoverflow.com/a/911213/1460422
|
|
if [ -t 1 ] || [[ ! -z "${FORCE_COLOUR}" ]]; then
|
|
###################
|
|
# From lantern.sh #
|
|
RS="\033[0m" # reset
|
|
HC="\033[1m" # hicolor
|
|
LC="\033[2m" # locolor / dim
|
|
###################
|
|
fi
|
|
|
|
log_msg() {
|
|
echo -e "${HC}>>>${RS} ${LC}[ ${SECONDS} ]${RS} $*" >&2;
|
|
}
|
|
|
|
###############################################################################
|
|
|
|
|
|
log_msg "Downloading mapserver";
|
|
curl -sSL -o "${temp_dir}/mapserver" "${download_url}"
|
|
|
|
chmod +x "${temp_dir}/mapserver";
|
|
|
|
log_msg "Determining version";
|
|
version="$(curl -sSL https://api.github.com/repos/minetest-mapserver/mapserver/releases/latest | jq --raw-output .tag_name)";
|
|
|
|
log_msg "Version is ${version}";
|
|
|
|
log_msg "Preparing docker build context";
|
|
|
|
cp ./Dockerfile "${temp_dir}/Dockerfile";
|
|
|
|
log_msg "Building docker image";
|
|
|
|
docker_image_name="${DOCKER_REGISTRY}minetest-mapserver:${arch}";
|
|
docker build "${temp_dir}" --tag "${docker_image_name}";
|
|
|
|
log_msg "Pushing to ${DOCKER_REGISTRY}";
|
|
docker push "${docker_image_name}";
|