Files
alpine-base/base-image-script/alpine-base_pt1.sh
fithwum 8e986c7b8b
Some checks failed
Build Alpine RootFS and Docker Image (latest) / build-rootfs (push) Failing after 13s
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 skipped
Build Alpine RootFS and Docker Image (latest) / update-changelog (push) Has been skipped
Build Alpine RootFS and Docker Image (latest) / update-build-info (push) Has been skipped
test
2025-07-06 08:54:33 -07:00

39 lines
1.3 KiB
Bash

#!/bin/bash
# Copyright (c) 2025 fithwum
# All rights reserved
set -e
# Alpine version
ALPINE_VERSION="v3.20"
BUILD_DIR="/mnt/alpine-rootfs" # <--- use safe path NOT in bind mount
OUTPUT_TAR="alpine-base.tar.gz"
PACKAGES="bash curl ca-certificates nano"
echo "[INFO] Downloading alpine-make-rootfs if needed..."
if [ ! -f ./alpine-make-rootfs ]; then
wget https://raw.githubusercontent.com/alpinelinux/alpine-make-rootfs/master/alpine-make-rootfs
chmod +x alpine-make-rootfs
fi
echo "[INFO] Creating Alpine rootfs with selected packages..."
sudo ./alpine-make-rootfs \
--branch "$ALPINE_VERSION" \
--mirror http://dl-cdn.alpinelinux.org/alpine \
--packages "$PACKAGES" \
"$BUILD_DIR"
echo "[INFO] Binding system directories for chroot..."
sudo mount --bind /dev "$BUILD_DIR/dev"
sudo mount --bind /proc "$BUILD_DIR/proc"
sudo mount --bind /sys "$BUILD_DIR/sys"
echo "[INFO] Copying part 2 script into chroot..."
sudo cp base-image-script/alpine-base_pt2.sh "$BUILD_DIR/alpine-base_pt2.sh"
sudo chmod +x "$BUILD_DIR/alpine-base_pt2.sh"
echo "[INFO] Entering chroot. Run 'exit' when done."
sudo chroot "$BUILD_DIR" /alpine-base_pt2.sh
echo "[INFO] Continuing with packaging after chroot..."
bash base-image-script/alpine-base_pt3.sh "$BUILD_DIR" "$OUTPUT_TAR"