From e35da6fc7bf4c3ca554c534e2b72922c7bfe1bed Mon Sep 17 00:00:00 2001 From: Malfurious Date: Wed, 9 Aug 2023 01:43:40 -0400 Subject: acid: Add service build helper script This is a merged version of a normal service builder and a cychedelic self-builder. Signed-off-by: Malfurious --- acid/cyche-build | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100755 acid/cyche-build (limited to 'acid/cyche-build') diff --git a/acid/cyche-build b/acid/cyche-build new file mode 100755 index 0000000..586e230 --- /dev/null +++ b/acid/cyche-build @@ -0,0 +1,48 @@ +#!/bin/bash -e + +# cyche-build [--self] +# +# (Re)build and deploy docker services using the files associated with . +# +# In the typical case, this is a straightforward process and `docker compose up` +# can properly recreate/start containers for the guest service. However, when +# rebuilding cychedelic itself, --self must be given, to instruct this file to +# modify its behavior to support self-upgrade of the running compose service. +# +# In `--self` mode, we prepare and start the cychedelic service under an +# alternate project name each time, before taking down the existing (old) +# services. This is necessary because running `docker compose up` terminates +# old containers before starting new one. Termination of the ACID service +# interrupts the `compose up` process before it can start the replacements. +# Normally, `docker compose down` is then not needed. +# +# We take (from cyche-source) so we may commit it to the cache iff the +# deployment is successful. +# +# This file exits early on any failure (non-zero). On a successful run in +# `--self` mode, this file does not exit (we are killed by `compose down`). + +cd "/services/$1" + +if [ "$3" == "--self" ]; then + slug=$(echo -n "$1-"; tr -dc a-z .git/previous_hash + +if [ "$3" == "--self" ]; then + echo "$slug" >.git/previous_slug + docker compose $prev down +fi -- cgit v1.2.3