Basic alpine chroot
This commit is contained in:
3
alpine/build-rootfs.sh
Executable file
3
alpine/build-rootfs.sh
Executable file
@@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
|
||||
|
||||
16
alpine/prepare-chroot.sh
Executable file
16
alpine/prepare-chroot.sh
Executable file
@@ -0,0 +1,16 @@
|
||||
#!/bin/bash
|
||||
|
||||
mkdir -p "$ROOTFS/var/cache/apk"
|
||||
mount --bind /var/cache/apk "$ROOTFS/var/cache/apk"
|
||||
mount --bind /dev "$ROOTFS/dev"
|
||||
mount --bind /proc "$ROOTFS/proc"
|
||||
mount --bind /sys "$ROOTFS/sys"
|
||||
mount --bind /run "$ROOTFS/run"
|
||||
|
||||
cp /usr/bin/qemu-aarch64-static "$ROOTFS/usr/bin/"
|
||||
cp /etc/resolv.conf "$ROOTFS/etc/resolv.conf"
|
||||
|
||||
chroot "$ROOTFS" /bin/sh -c "ln -s /var/cache/apk /etc/apk/cache"
|
||||
chroot "$ROOTFS" /bin/sh -c "apk update; apk add bash curl"
|
||||
cp "/build-rootfs.sh" "$ROOTFS/build-rootfs.sh"
|
||||
chroot "$ROOTFS" /bin/bash /build-rootfs.sh
|
||||
@@ -19,3 +19,6 @@ CROSS_COMPILE=aarch64-linux-gnu-
|
||||
# Busybox for initramfs
|
||||
BUSYBOX_VERSION=1_36_1
|
||||
|
||||
## Alpine Linux
|
||||
ALPINE_VER=3.23.3
|
||||
ALPINE_ARCH=aarch64
|
||||
|
||||
22
docker/alpine.Dockerfile
Normal file
22
docker/alpine.Dockerfile
Normal file
@@ -0,0 +1,22 @@
|
||||
ARG TAG=dev
|
||||
ARG DOCKER_IMAGE_ROOT=monok8s
|
||||
FROM --platform=linux/amd64 ${DOCKER_IMAGE_ROOT}/build-base:${TAG} AS build-base
|
||||
|
||||
ARG ALPINE_ARCH
|
||||
ARG ALPINE_VER
|
||||
|
||||
RUN apt-get update && apt-get install -y qemu-user-static --no-install-recommends
|
||||
|
||||
RUN mkdir -p "/out/rootfs"
|
||||
|
||||
# RUN curl -L \
|
||||
# "https://dl-cdn.alpinelinux.org/alpine/v3.21/releases/${ALPINE_ARCH}/alpine-minirootfs-${ALPINE_VER}-${ALPINE_ARCH}.tar.gz" \
|
||||
# -o alpine-minirootfs.tar.gz
|
||||
# RUN tar -xzf alpine-minirootfs.tar.gz -C "/out/rootfs"
|
||||
|
||||
# Dev-only shortcut
|
||||
COPY dev/alpine.tar.gz ./
|
||||
|
||||
RUN tar -xf alpine.tar.gz -C "/out/rootfs"
|
||||
|
||||
COPY alpine/*.sh /
|
||||
18
makefile
18
makefile
@@ -39,3 +39,21 @@ itb: fit-build
|
||||
--build-arg DEVICE_TREE_TARGET=$(DEVICE_TREE_TARGET) \
|
||||
--output type=local,dest=./out \
|
||||
-t $(DOCKER_IMAGE_ROOT)/itb:$(TAG) .
|
||||
|
||||
buildenv-alpine: build-base
|
||||
docker build \
|
||||
-f docker/alpine.Dockerfile \
|
||||
--build-arg DOCKER_IMAGE_ROOT=$(DOCKER_IMAGE_ROOT) \
|
||||
--build-arg TAG=$(TAG) \
|
||||
--build-arg ALPINE_ARCH=$(ALPINE_ARCH) \
|
||||
--build-arg ALPINE_VER=$(ALPINE_VER) \
|
||||
-t $(DOCKER_IMAGE_ROOT)/buildenv-alpine:$(TAG) .
|
||||
|
||||
alpine-rootfs: buildenv-alpine
|
||||
docker run --rm -it \
|
||||
--privileged \
|
||||
-v /cache/apk:/var/cache/apk \
|
||||
-v /cache/artifacts:/artifacts \
|
||||
-e ROOTFS=/out/rootfs \
|
||||
$(DOCKER_IMAGE_ROOT)/buildenv-alpine:$(TAG) \
|
||||
bash -lc '/prepare-chroot.sh && /build-rootfs.sh'
|
||||
|
||||
Reference in New Issue
Block a user