72 lines
3.5 KiB
Bash
Executable File
72 lines
3.5 KiB
Bash
Executable File
#!/bin/sh
|
|
# A delivery of ISSSTELEON from HEAD, installable with no registry and no internet:
|
|
# README.md the only document: how to install, operate and update it (Spanish)
|
|
# codigo/ the product's source, exported with `git archive` (each submodule at its pinned
|
|
# commit, never the working tree), then pruned by tools/delivery/prune.py: no tests,
|
|
# synthetic site, tools or fixtures; no docstrings, comments or other documents
|
|
# deploy/ deploy/ from codigo/, VERSION, and imagenes/: the app and web images built from
|
|
# codigo/, plus the images they run beside (MLflow), saved and checksummed
|
|
#
|
|
# ./entregar.sh [destination] [version]
|
|
# The version defaults to the tag on HEAD (v1.2.3), else today's date. The destination
|
|
# defaults to ../ISSSTELEON-entrega-<version>. INCLUIR_LLM=1 also packs the local LLM image.
|
|
set -eu
|
|
HERE="$(cd "$(dirname "$0")" && pwd)"
|
|
cd "$HERE"
|
|
|
|
fail() { echo "ERROR: $*" >&2; exit 1; }
|
|
say() { echo "==> $*"; }
|
|
|
|
[ -d .git ] || [ -f .git ] || fail "Run this from the repository root."
|
|
[ -z "$(git status --porcelain)" ] || fail "Uncommitted changes: git archive packs HEAD only. Commit or stash them first."
|
|
git submodule status | grep -q '^[+-]' && fail "A submodule is not at its pinned commit (git submodule status)." || true
|
|
|
|
VERSION="${2:-$(git describe --tags --exact-match 2>/dev/null || date +%Y.%m.%d)}"
|
|
DEST="${1:-$HERE/../ISSSTELEON-entrega-$VERSION}"
|
|
[ -e "$DEST" ] && fail "$DEST exists; remove it or pass another destination."
|
|
mkdir -p "$DEST/codigo" "$DEST/deploy/imagenes"
|
|
|
|
say "Exporting HEAD ($(git rev-parse --short HEAD)) to codigo/"
|
|
git archive HEAD | tar -x -C "$DEST/codigo"
|
|
git submodule status | while read -r line; do
|
|
sha="$(echo "$line" | awk '{print $1}' | tr -d '+-')"
|
|
path="$(echo "$line" | awk '{print $2}')"
|
|
say " $path @ $sha"
|
|
mkdir -p "$DEST/codigo/$path"
|
|
git -C "$path" archive "$sha" | tar -x -C "$DEST/codigo/$path"
|
|
done
|
|
|
|
say "Pruning codigo/ to the product, without documentation"
|
|
[ -d "$HERE/WebApp/node_modules/typescript" ] || fail "Run 'npm ci' in WebApp first (the TypeScript printer strips its comments)."
|
|
python3 "$HERE/tools/delivery/prune.py" "$DEST/codigo" "$HERE/WebApp/node_modules/typescript"
|
|
|
|
say "Building the images ($VERSION) from codigo/"
|
|
docker build --target app -t "isssteleon/app:$VERSION" "$DEST/codigo"
|
|
docker build -t "isssteleon/web:$VERSION" "$DEST/codigo/WebApp"
|
|
EXTERNAL="$(grep -h '^ *image:' "$DEST/codigo/deploy/compose.yml" | awk '{print $2}' | grep -v '^isssteleon/' | sort -u)"
|
|
[ "${INCLUIR_LLM:-0}" = "1" ] || EXTERNAL="$(echo "$EXTERNAL" | grep -v '^ollama/')"
|
|
for image in $EXTERNAL; do
|
|
say "Pulling $image"
|
|
docker image inspect "$image" >/dev/null 2>&1 || docker pull "$image"
|
|
done
|
|
|
|
say "Saving the images"
|
|
for image in "isssteleon/app:$VERSION" "isssteleon/web:$VERSION" $EXTERNAL; do
|
|
file="$(echo "$image" | tr '/:' '__').tar.gz"
|
|
docker save "$image" | gzip -1 > "$DEST/deploy/imagenes/$file"
|
|
done
|
|
( cd "$DEST/deploy/imagenes" && sha256sum ./*.tar.gz > SHA256SUMS )
|
|
|
|
say "Assembling deploy/"
|
|
cp -a "$DEST/codigo/deploy/." "$DEST/deploy/"
|
|
echo "$VERSION" > "$DEST/deploy/VERSION"
|
|
chmod +x "$DEST/deploy/isssteleon.sh"
|
|
if grep -rIil "erick" "$DEST" --exclude-dir=imagenes; then
|
|
fail "Forbidden words in the delivery (listed above)."
|
|
fi
|
|
|
|
say "Done: $DEST"
|
|
say " README.md how to install and operate it"
|
|
say " codigo/ the source of this version"
|
|
say " deploy/ copy it to the server, then: cp .env.ejemplo .env; edit it; ./isssteleon.sh instalar"
|