test
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

This commit is contained in:
2025-07-06 08:27:36 -07:00
parent 9a67103da1
commit f5819d27e4
2 changed files with 27 additions and 20 deletions

View File

@@ -28,11 +28,11 @@ sudo mount --bind /proc "$ROOTFS_DIR/proc"
sudo mount --bind /sys "$ROOTFS_DIR/sys" sudo mount --bind /sys "$ROOTFS_DIR/sys"
echo "[INFO] Copying part 2 script into chroot..." echo "[INFO] Copying part 2 script into chroot..."
sudo cp alpine-base_pt2.sh "$ROOTFS_DIR/alpine-base_pt2.sh" sudo cp base-image-script/alpine-base_pt2.sh "$ROOTFS_DIR/alpine-base_pt2.sh"
sudo chmod +x "$ROOTFS_DIR/alpine-base_pt2.sh" sudo chmod +x "$ROOTFS_DIR/alpine-base_pt2.sh"
echo "[INFO] Entering chroot. Run 'exit' when done." echo "[INFO] Entering chroot. Run 'exit' when done."
sudo chroot "$ROOTFS_DIR" /alpine-base_pt2.sh sudo chroot "$ROOTFS_DIR" /alpine-base_pt2.sh
echo "[INFO] Continuing with packaging after chroot..." echo "[INFO] Continuing with packaging after chroot..."
bash alpine-base_pt3.sh "$ROOTFS_DIR" "$OUTPUT_TAR" bash base-image-script/alpine-base_pt3.sh "$ROOTFS_DIR" "$OUTPUT_TAR"

View File

@@ -3,28 +3,35 @@
# All rights reserved # All rights reserved
set -e set -e
ROOTFS_DIR="$1" # Auto-detect rootfs dir if not passed as arg
OUTPUT_TAR="$2" 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
echo "[INFO] Unmounting system dirs..." # Define output tarball location (adjust as needed)
sudo umount -lf "$ROOTFS_DIR/dev" TARBALL="/output/${ROOTFS_DIR}.tar.gz"
sudo umount -lf "$ROOTFS_DIR/proc"
sudo umount -lf "$ROOTFS_DIR/sys"
echo "[INFO] Cleaning up chroot script..." echo "[INFO] Unmounting system directories (ignore errors)..."
sudo rm -f "$ROOTFS_DIR/alpine-base_pt2.sh" for dir in dev proc sys; do
sudo umount -lf "$ROOTFS_DIR/$dir" 2>/dev/null || true
done
echo "[INFO] Creating tarball: $OUTPUT_TAR" echo "[INFO] Removing chroot script if exists..."
sudo tar -czf "$OUTPUT_TAR" -C "$ROOTFS_DIR" . sudo rm -f "$ROOTFS_DIR/alpine-base_pt2.sh" 2>/dev/null || true
echo "[INFO] Image size:" echo "[INFO] Rootfs size:"
du -sh "$OUTPUT_TAR" du -sh "$ROOTFS_DIR"
# OPTIONAL FTP upload echo "[INFO] Creating compressed base image tarball..."
echo "[INFO] Uploading via FTP..." sudo tar -czf "$TARBALL" -C "$ROOTFS_DIR" .
ftp-upload -v -h <IP> -u <USER> --password <PASS> -d /path "$OUTPUT_TAR"
echo "[INFO] Cleaning up rootfs directory..." echo "[INFO] Tarball size:"
sudo rm -rf "$ROOTFS_DIR" du -sh "$TARBALL"
echo "[INFO] Done." echo "[INFO] Tarball ready for CI to upload: $TARBALL"