paperless-ng: rewrite as base-nopush, using the official GH release assets

This commit is contained in:
Starbeamrainbowlabs 2021-01-14 01:23:45 +00:00
parent 8c484ed331
commit 0aac8436a5
Signed by: sbrl
GPG key ID: 1BE5172E637709C2
3 changed files with 84 additions and 0 deletions

View file

@ -9,6 +9,7 @@ fi
lantern_path="${repo_root}/lantern-build-engine"; lantern_path="${repo_root}/lantern-build-engine";
IMAGEBUILDER_REGISTRY="${IMAGEBUILDER_REGISTRY:-registry.service.mooncarrot.space:5000}"; IMAGEBUILDER_REGISTRY="${IMAGEBUILDER_REGISTRY:-registry.service.mooncarrot.space:5000}";
export IMAGEBUILDER_REGISTRY;
############################################################################### ###############################################################################

View file

@ -0,0 +1,82 @@
#!/usr/bin/env bash
username="jonaswinkler";
reponame="paperless-ng";
output_dir="${1}";
###############################################################################
log_msg() {
# echo "[github-get-releases] [${SECONDS}] $*" >&2;
echo "[docker-images/paperless-ng] $*" >&2;
}
if [[ -z "${output_dir}" ]]; then
echo "Error: No output directory specified.
paperless-ng build script
Usage:
./paperless-ng.sh <path/to/preexisting_output_dir>" >&2;
exit 0;
fi
if [[ ! -d "${output_dir}" ]]; then
echo "Error: Output directory doesn't exist." >&2;
exit 1;
fi
temp_dir="$(mktemp --tmpdir -d "docker-images-paperless-ng-XXXXXXX")";
on_exit() {
log_msg "Cleaning up";
rm -rf "${temp_dir}";
log_msg "Cleanup complete";
}
trap on_exit EXIT;
cd "${temp_dir}" || { echo "Failed to cd to temp dir"; exit 1; };
###############################################################################
###
# Step 1: Download and extract GitHub asset
###
release_json_url="https://api.github.com/repos/${username}/${reponame}/releases?per_page=1";
asset_urls="$(curl -sSL "${release_json_url}" | jq --raw-output '.[0].assets[] | [.name, .browser_download_url] | @tsv')";
while read -r filename url; do
if [[ "${filename}" == *"docker"* ]]; then
log_msg "Skipping docker compose definitions";
continue;
fi
download_loc="paperless.tar.xz";
curl -sSL -o "${download_loc}" "${url}";
tar -xf "${download_loc}";
rm "${download_loc}";
cd "paperless-ng" || { echo "Failed to cd into extracted paperless-ng directory"; exit 1; };
break;
done < <(echo "${asset_urls}");
###############################################################################
###
# Step 2: Build and push the docker image
###
# Note to self: All settings are environment variables, which are specified in
# the Nomad jobspec file
docker_tag="${IMAGEBUILDER_REGISTRY}/paperless-ng";
log_msg "Building docker image";
docker build --no-cache --pull --tag "${docker_tag}" .;
log_msg "Pushing docker image";
docker push "${docker_tag}";
log_msg "done";

View file

@ -0,0 +1 @@
base-nopush