Enhance development environment with automatic Dev-Hosts synchronization and update provisioning script to clone repositories directly

This commit is contained in:
2026-04-15 10:04:01 +02:00
parent 55b3ea15d6
commit 7e7bb707a1
7 changed files with 33 additions and 39 deletions
+1
View File
@@ -157,6 +157,7 @@ Im Ordner `Website/` gibt es zwei Launcher-Skripte:
- `./launch_dev.sh`
- setzt `INSTANCE_TLS_MODE=development`
- erzeugt pro Subdomain self-signed Zertifikate (wenn moeglich)
- synchronisiert die Dev-Hosts jetzt beim Start und danach regelmaessig neu
- setzt `SESSION_COOKIE_SECURE=0`
- `./launch_prod.sh`
+1
View File
@@ -10,6 +10,7 @@ RUN apt-get update \
git \
iproute2 \
docker.io \
sudo \
curl \
openssl \
ca-certificates \
View File
+7
View File
@@ -7,17 +7,24 @@ cd "$SCRIPT_DIR"
export SESSION_COOKIE_SECURE="0"
export INSTANCE_TLS_MODE="development"
export INSTANCE_PARENT_DOMAIN="${INSTANCE_PARENT_DOMAIN:-meine-domain}"
export DEV_HOSTS_REFRESH_INTERVAL="${DEV_HOSTS_REFRESH_INTERVAL:-30}"
echo "Launching DEVELOPMENT stack"
echo " SESSION_COOKIE_SECURE=$SESSION_COOKIE_SECURE"
echo " INSTANCE_TLS_MODE=$INSTANCE_TLS_MODE"
echo " INSTANCE_PARENT_DOMAIN=$INSTANCE_PARENT_DOMAIN"
echo " DEV_HOSTS_REFRESH_INTERVAL=$DEV_HOSTS_REFRESH_INTERVAL"
docker compose build website
docker compose up -d
if [[ -x "$SCRIPT_DIR/sync_dev_hosts.sh" ]]; then
"$SCRIPT_DIR/sync_dev_hosts.sh" || true
if [[ "${DEV_HOSTS_REFRESH_INTERVAL}" != "0" ]]; then
nohup bash -lc "while true; do '$SCRIPT_DIR/sync_dev_hosts.sh' >/dev/null 2>&1 || true; sleep '$DEV_HOSTS_REFRESH_INTERVAL'; done" \
>"$SCRIPT_DIR/dev-hosts-sync.log" 2>&1 &
echo " Dev-Hosts-Sync läuft im Hintergrund (Log: $SCRIPT_DIR/dev-hosts-sync.log)"
fi
fi
echo "Development stack is running on http://localhost:4999"
+7 -19
View File
@@ -237,8 +237,6 @@ run_instance_start() {
setup_or_update_repo() {
local target_dir="$1"
local repo_url="$2"
local installer_url="https://raw.githubusercontent.com/AIIrondev/legendary-octo-garbanzo/main/install.sh"
local installer_script=""
if [ -f "$target_dir/start.sh" ]; then
# Existing installation: keep it docker-only and update via project tooling.
@@ -252,25 +250,15 @@ setup_or_update_repo() {
fail "Zielverzeichnis ist nicht leer: $target_dir"
fi
mkdir -p "$target_dir"
installer_script="$(mktemp)"
if ! wget -qO- "$installer_url" > "$installer_script"; then
rm -f "$installer_script"
fail "Installer konnte nicht geladen werden: $installer_url"
# Clone directly instead of running the upstream installer, which expects
# host-level systemd/cron setup and can fail inside containers.
if [ -d "$target_dir" ]; then
rmdir "$target_dir" 2>/dev/null || true
fi
# Patch only the target directory variable so we can install per instance.
if ! sed -i "s|^PROJECT_DIR=.*$|PROJECT_DIR=\"$target_dir\"|" "$installer_script"; then
rm -f "$installer_script"
fail "Installer konnte nicht vorbereitet werden."
if ! git clone --depth 1 "$repo_url" "$target_dir" >/dev/null 2>&1; then
fail "Repository konnte nicht geklont werden: $repo_url"
fi
if ! bash "$installer_script" --skip-cleanup-old; then
rm -f "$installer_script"
fail "Installer-Ausführung fehlgeschlagen."
fi
rm -f "$installer_script"
}
write_nginx_site() {
@@ -465,7 +453,7 @@ FULL_DOMAIN="$SUBDOMAIN.$PARENT_DOMAIN"
require_cmd docker
require_cmd bash
require_cmd wget
require_cmd git
mkdir -p "$BASE_DIR"
+10 -1
View File
@@ -8,6 +8,15 @@ HOSTS_FILE="/etc/hosts"
START_MARK="# >>> invario-dev-hosts >>>"
END_MARK="# <<< invario-dev-hosts <<<"
HOST_IP="${DEV_HOSTS_IP:-}"
if [[ -z "$HOST_IP" ]]; then
HOST_IP="$(hostname -I 2>/dev/null | awk '{print $1}')"
fi
if [[ -z "$HOST_IP" ]]; then
HOST_IP="127.0.0.1"
fi
if ! command -v docker >/dev/null 2>&1; then
echo "docker fehlt; Hosts-Sync übersprungen"
exit 0
@@ -29,7 +38,7 @@ trap 'rm -f "$TMP_BLOCK"' EXIT
while IFS= read -r line; do
domain="$(echo "$line" | tr -d '\r' | xargs)"
if [[ -n "$domain" ]]; then
echo "127.0.0.1 $domain"
echo "$HOST_IP $domain"
fi
done <<< "$DOMAINS_RAW"
echo "$END_MARK"
+7 -19
View File
@@ -229,8 +229,6 @@ run_instance_start() {
setup_or_update_repo() {
local target_dir="$1"
local repo_url="$2"
local installer_url="https://raw.githubusercontent.com/AIIrondev/legendary-octo-garbanzo/main/install.sh"
local installer_script=""
if [ -f "$target_dir/start.sh" ]; then
# Existing installation: keep it docker-only and update via project tooling.
@@ -244,25 +242,15 @@ setup_or_update_repo() {
fail "Zielverzeichnis ist nicht leer: $target_dir"
fi
mkdir -p "$target_dir"
installer_script="$(mktemp)"
if ! wget -qO- "$installer_url" > "$installer_script"; then
rm -f "$installer_script"
fail "Installer konnte nicht geladen werden: $installer_url"
# Clone directly instead of running the upstream installer, which expects
# host-level systemd/cron setup and can fail inside containers.
if [ -d "$target_dir" ]; then
rmdir "$target_dir" 2>/dev/null || true
fi
# Patch only the target directory variable so we can install per instance.
if ! sed -i "s|^PROJECT_DIR=.*$|PROJECT_DIR=\"$target_dir\"|" "$installer_script"; then
rm -f "$installer_script"
fail "Installer konnte nicht vorbereitet werden."
if ! git clone --depth 1 "$repo_url" "$target_dir" >/dev/null 2>&1; then
fail "Repository konnte nicht geklont werden: $repo_url"
fi
if ! bash "$installer_script" --skip-cleanup-old; then
rm -f "$installer_script"
fail "Installer-Ausführung fehlgeschlagen."
fi
rm -f "$installer_script"
}
write_nginx_site() {
@@ -457,7 +445,7 @@ FULL_DOMAIN="$SUBDOMAIN.$PARENT_DOMAIN"
require_cmd docker
require_cmd bash
require_cmd wget
require_cmd git
mkdir -p "$BASE_DIR"