Changes from old deployment system to new dynamic one
This commit is contained in:
+2
-30
@@ -82,7 +82,6 @@ while i < len(lines):
|
||||
stripped = line.lstrip(" ")
|
||||
indent = leading_spaces(line)
|
||||
|
||||
# Check if we're starting the app service
|
||||
if not in_app_service and re.match(r"^\s*app:\s*$", line):
|
||||
in_app_service = True
|
||||
app_indent = indent
|
||||
@@ -92,9 +91,7 @@ while i < len(lines):
|
||||
i += 1
|
||||
continue
|
||||
|
||||
# Check if we've exited the app service (found another top-level service)
|
||||
if in_app_service and indent <= app_indent and re.match(r"^[A-Za-z0-9_-]+:\s*$", stripped):
|
||||
# We've left the app service - insert image if we haven't already
|
||||
if build_found and app_service_indent is not None:
|
||||
out.append(f"{' ' * app_service_indent}image: {target_image}\n")
|
||||
in_app_service = False
|
||||
@@ -102,24 +99,20 @@ while i < len(lines):
|
||||
i += 1
|
||||
continue
|
||||
|
||||
# Process lines within the app service
|
||||
if in_app_service:
|
||||
if app_service_indent is None and indent > app_indent:
|
||||
app_service_indent = indent
|
||||
|
||||
# Check for image key (already has an image, don't add)
|
||||
if re.match(rf"^\s+image:\s*", line):
|
||||
in_app_service = False
|
||||
out.append(line)
|
||||
i += 1
|
||||
continue
|
||||
|
||||
# Check for build block
|
||||
if re.match(rf"^\s+build:\s*$", line):
|
||||
build_found = True
|
||||
out.append(line)
|
||||
i += 1
|
||||
# Skip all lines that are part of the build block (indented more than app_service_indent)
|
||||
while i < len(lines):
|
||||
next_line = lines[i]
|
||||
next_indent = leading_spaces(next_line)
|
||||
@@ -130,12 +123,10 @@ while i < len(lines):
|
||||
break
|
||||
continue
|
||||
|
||||
# Insert image after build block before first property
|
||||
if build_found and app_service_indent is not None and indent == app_service_indent:
|
||||
# Check if this is a property line (not build)
|
||||
if not re.match(rf"^\s+build:", line):
|
||||
out.append(f"{' ' * app_service_indent}image: {target_image}\n")
|
||||
build_found = False # Mark that we've inserted the image
|
||||
build_found = False
|
||||
|
||||
out.append(line)
|
||||
i += 1
|
||||
@@ -144,7 +135,6 @@ while i < len(lines):
|
||||
out.append(line)
|
||||
i += 1
|
||||
|
||||
# If we ended while still in the app service, append image at the end
|
||||
if in_app_service and build_found and app_service_indent is not None:
|
||||
out.append(f"{' ' * app_service_indent}image: {target_image}\n")
|
||||
|
||||
@@ -377,18 +367,12 @@ with open(meta_file, 'r', encoding='utf-8') as f:
|
||||
data = json.load(f)
|
||||
tag = data.get('tag_name', '').strip()
|
||||
url = ''
|
||||
image_url = ''
|
||||
for asset in data.get('assets', []):
|
||||
if asset.get('name') == asset_name:
|
||||
url = asset.get('browser_download_url', '').strip()
|
||||
break
|
||||
for asset in data.get('assets', []):
|
||||
if asset.get('name') == f'inventarsystem-image-{tag}.tar.gz':
|
||||
image_url = asset.get('browser_download_url', '').strip()
|
||||
break
|
||||
print(tag)
|
||||
print(url)
|
||||
print(image_url)
|
||||
PY
|
||||
}
|
||||
|
||||
@@ -401,7 +385,7 @@ main() {
|
||||
need_cmd python3
|
||||
need_cmd curl
|
||||
|
||||
local meta_file tag bundle_url image_url
|
||||
local meta_file tag bundle_url
|
||||
TMP_DIR="$(mktemp -d)"
|
||||
meta_file="$TMP_DIR/release.json"
|
||||
trap cleanup_tmp_dir EXIT
|
||||
@@ -409,7 +393,6 @@ main() {
|
||||
mapfile -t release_info < <(latest_tag_and_bundle_url "$meta_file")
|
||||
tag="${release_info[0]:-}"
|
||||
bundle_url="${release_info[1]:-}"
|
||||
image_url="${release_info[2]:-}"
|
||||
|
||||
if [ -z "$tag" ] || [ -z "$bundle_url" ]; then
|
||||
echo "Error: latest release metadata is incomplete."
|
||||
@@ -425,17 +408,6 @@ main() {
|
||||
|
||||
pin_compose_app_image "$tag"
|
||||
|
||||
if [ -z "$image_url" ]; then
|
||||
echo "Error: release image asset is missing"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
curl -fL "$image_url" -o "$TMP_DIR/inventarsystem-image-$tag.tar.gz"
|
||||
sudo docker load -i "$TMP_DIR/inventarsystem-image-$tag.tar.gz" >/dev/null
|
||||
|
||||
# Tagge das geladene Gitea-Image als latest
|
||||
sudo docker tag "git.invario-software.eu/invario/inventarsystem:$tag" "git.invario-software.eu/invario/inventarsystem:latest" >/dev/null 2>&1 || true
|
||||
|
||||
if [ ! -f "$PROJECT_DIR/start.sh" ]; then
|
||||
echo "Error: release bundle is missing start.sh"
|
||||
exit 1
|
||||
|
||||
Reference in New Issue
Block a user