From a5a179a7f250d979175eac4fc25e758fae022a6f Mon Sep 17 00:00:00 2001 From: Nils-Johan Gynther Date: Sun, 3 May 2026 14:02:57 +0200 Subject: [PATCH] feat(rebuild-script): add script to rebuild and restart Flutter service with Docker --- scripts/rebuild_flutter.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 scripts/rebuild_flutter.sh diff --git a/scripts/rebuild_flutter.sh b/scripts/rebuild_flutter.sh new file mode 100644 index 00000000..1f997974 --- /dev/null +++ b/scripts/rebuild_flutter.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env bash +set -Eeuo pipefail + +APP_DIR="${1:-/opt/containers/recipe-app}" +COMPOSE_FILES=(-f compose.yml -f compose.flutter.yml) +SERVICE="recipe-flutter" + +log() { echo "[flutter-rebuild] $*"; } +fail() { echo "[flutter-rebuild][ERROR] $*" >&2; exit 1; } + +cd "$APP_DIR" || fail "Kunde inte byta till katalog: $APP_DIR" + +if ! docker compose version >/dev/null 2>&1; then + fail "docker compose saknas eller fungerar inte" +fi + +if [ ! -f "compose.yml" ] || [ ! -f "compose.flutter.yml" ]; then + fail "compose.yml eller compose.flutter.yml saknas i $APP_DIR" +fi + +log "Bygger om $SERVICE" +docker compose "${COMPOSE_FILES[@]}" build "$SERVICE" + +log "Startar om $SERVICE" +docker compose "${COMPOSE_FILES[@]}" up -d "$SERVICE" + +log "Status" +docker compose "${COMPOSE_FILES[@]}" ps "$SERVICE" + +log "Klart"