Files
alpine-base/base-image-script/alpine-base_pt3.sh
fithwum f5819d27e4
Some checks failed
Build Alpine RootFS and Docker Image (latest) / build-rootfs (push) Failing after 8s
Build Alpine RootFS and Docker Image (latest) / push-tarball (push) Has been skipped
Build Alpine RootFS and Docker Image (latest) / push-docker (push) Has been cancelled
Build Alpine RootFS and Docker Image (latest) / update-changelog (push) Has been cancelled
Build Alpine RootFS and Docker Image (latest) / update-build-info (push) Has been cancelled
test
2025-07-06 08:27:36 -07:00

38 lines
973 B
Bash

#!/bin/bash
# Copyright (c) 2025 fithwum
# All rights reserved
set -e
# Auto-detect rootfs dir if not passed as arg
if [ -n "$1" ]; then
ROOTFS_DIR="$1"
else
ROOTFS_DIR=$(find . -maxdepth 1 -type d -name "alpine-rootfs" | sed 's|^\./||' | head -n 1)
if [ -z "$ROOTFS_DIR" ]; then
echo "[ERROR] No alpine-rootfs directory found!"
exit 1
fi
fi
# Define output tarball location (adjust as needed)
TARBALL="/output/${ROOTFS_DIR}.tar.gz"
echo "[INFO] Unmounting system directories (ignore errors)..."
for dir in dev proc sys; do
sudo umount -lf "$ROOTFS_DIR/$dir" 2>/dev/null || true
done
echo "[INFO] Removing chroot script if exists..."
sudo rm -f "$ROOTFS_DIR/alpine-base_pt2.sh" 2>/dev/null || true
echo "[INFO] Rootfs size:"
du -sh "$ROOTFS_DIR"
echo "[INFO] Creating compressed base image tarball..."
sudo tar -czf "$TARBALL" -C "$ROOTFS_DIR" .
echo "[INFO] Tarball size:"
du -sh "$TARBALL"
echo "[INFO] Tarball ready for CI to upload: $TARBALL"