From 7e1e2eb6ed89e67e8dbf9fec1f9af0183eef6085 Mon Sep 17 00:00:00 2001 From: Producer Matt <58014742+ProducerMatt@users.noreply.github.com> Date: Sun, 2 Jul 2023 20:44:54 -0500 Subject: [PATCH 1/2] update-shared-stampy script --- scripts/update-shared-stampys.sh | 64 ++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 scripts/update-shared-stampys.sh diff --git a/scripts/update-shared-stampys.sh b/scripts/update-shared-stampys.sh new file mode 100644 index 0000000..95a00f0 --- /dev/null +++ b/scripts/update-shared-stampys.sh @@ -0,0 +1,64 @@ +#!/bin/bash + +# This script is for use on the Stampy server managing multiple docker instances. + +set -eu + +PROJECT_DIR=$HOME +host_list=$(cat ~/served_hosts) + +sanity_check() { + local target="${PROJECT_DIR}/$1" + local task="check dir '${target}'exists" + cd "${target}" && echo "$task: $1" + if [ ! -d "${target}/.git" ]; then + echo "Dir ${target}/.git does not exist" + exit 1 + fi +} +git_update () { + local task="update and prune git repo" + cd "${PROJECT_DIR}/$1" && echo "$task: $1" + git pull --rebase=true --depth=1 -q + git gc --prune=now -q +} +image_build () { + local task="build image" + cd "${PROJECT_DIR}/$1" && echo "$task: $1" + podman-compose --podman-args '--format=docker --pull=newer -q' build +} +actually_update () { + local task="restart service" + cd "${PROJECT_DIR}/$1" && echo "$task: $1" + podman-compose down + podman-compose up -d +} +post_cleanup () { + echo "prune intermediate images" + podman system prune -af +} + +sanity_check "stampy" +for host in $host_list; do + sanity_check $host +done + +# Main stampy folder should have been updated by external action, +# as to update this script. +for host in $host_list; do + git_update $host +done + +for host in $host_list; do + image_build $host +done + +for host in $host_list; do + actually_update $host +done + +post_cleanup + +echo "Update script successful!" + +exit 0 From d9732e56381f42b49e6ead7c4cf767b858b26e66 Mon Sep 17 00:00:00 2001 From: Producer Matt <58014742+ProducerMatt@users.noreply.github.com> Date: Mon, 3 Jul 2023 00:20:25 -0500 Subject: [PATCH 2/2] Dockerfile: remove 300MB of tarballs --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index 527d71c..b93f0bc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,6 +18,7 @@ RUN --mount=type=cache,mode=0755,target=/root/.cache/pip conda env create -f env RUN echo "conda activate stampy" >> ~/.profile SHELL ["/bin/bash", "--login", "-c"] RUN --mount=type=cache,mode=0755,target=/root/.cache/pip conda activate stampy && conda install pytest +RUN conda clean -a COPY . . ENV STAMPY_RUN_TESTS=${STAMPY_RUN_TESTS}