From f09bf380e9b1d6660b6664cf5c63f64bc8641fcb Mon Sep 17 00:00:00 2001 From: TheSpad Date: Sat, 7 Jan 2023 11:31:51 +0000 Subject: [PATCH] POC for building rootfs without external scripts --- .github/workflows/call_invalid_helper.yml | 12 +++++++++ Dockerfile | 27 ++++++++------------ Dockerfile.aarch64 | 26 ++++++++----------- Dockerfile.armhf | 26 ++++++++----------- root/etc/s6-overlay/s6-rc.d/init-adduser/run | 6 ++--- 5 files changed, 45 insertions(+), 52 deletions(-) create mode 100644 .github/workflows/call_invalid_helper.yml diff --git a/.github/workflows/call_invalid_helper.yml b/.github/workflows/call_invalid_helper.yml new file mode 100644 index 0000000..773767c --- /dev/null +++ b/.github/workflows/call_invalid_helper.yml @@ -0,0 +1,12 @@ +name: Comment on invalid interaction +on: + issues: + types: + - labeled +jobs: + add-comment-on-invalid: + if: github.event.label.name == 'invalid' + permissions: + issues: write + uses: linuxserver/github-workflows/.github/workflows/invalid-interaction-helper.yml@v1 + secrets: inherit diff --git a/Dockerfile b/Dockerfile index 87166a4..24d805a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,9 @@ # syntax=docker/dockerfile:1 -FROM alpine:3.17 as rootfs-stage +FROM alpine:3 as rootfs-stage # environment +ENV ROOTFS=/root-out ENV REL=edge ENV ARCH=x86_64 ENV MIRROR=http://dl-cdn.alpinelinux.org/alpine @@ -10,29 +11,22 @@ ENV PACKAGES=alpine-baselayout,\ alpine-keys,\ apk-tools,\ busybox,\ -libc-utils,\ -xz +libc-utils # install packages RUN \ apk add --no-cache \ bash \ - curl \ - tzdata \ xz -# fetch builder script from gliderlabs +# build rootfs RUN \ - curl -o \ - /mkimage-alpine.bash -L \ - https://raw.githubusercontent.com/gliderlabs/docker-alpine/master/builder/scripts/mkimage-alpine.bash && \ - chmod +x \ - /mkimage-alpine.bash && \ - ./mkimage-alpine.bash && \ - mkdir /root-out && \ - tar xf \ - /rootfs.tar.xz -C \ - /root-out && \ + mkdir -p "$ROOTFS/etc/apk" && \ + { \ + echo "$MIRROR/$REL/main"; \ + echo "$MIRROR/$REL/community"; \ + } > "$ROOTFS/etc/apk/repositories" && \ + apk --root "$ROOTFS" --no-cache --keys-dir /etc/apk/keys add --arch $ARCH --initdb ${PACKAGES//,/ } && \ sed -i -e 's/^root::/root:!:/' /root-out/etc/shadow # set version for s6 overlay @@ -78,7 +72,6 @@ RUN \ coreutils \ curl \ jq \ - procps \ shadow \ tzdata && \ echo "**** create abc user and make our folders ****" && \ diff --git a/Dockerfile.aarch64 b/Dockerfile.aarch64 index 9c0defc..13e803a 100644 --- a/Dockerfile.aarch64 +++ b/Dockerfile.aarch64 @@ -1,8 +1,9 @@ # syntax=docker/dockerfile:1 -FROM alpine:3.17 as rootfs-stage +FROM alpine:3 as rootfs-stage # environment +ENV ROOTFS=/root-out ENV REL=edge ENV ARCH=aarch64 ENV MIRROR=http://dl-cdn.alpinelinux.org/alpine @@ -10,29 +11,22 @@ ENV PACKAGES=alpine-baselayout,\ alpine-keys,\ apk-tools,\ busybox,\ -libc-utils,\ -xz +libc-utils # install packages RUN \ apk add --no-cache \ bash \ - curl \ - tzdata \ xz -# fetch builder script from gliderlabs +# build rootfs RUN \ - curl -o \ - /mkimage-alpine.bash -L \ - https://raw.githubusercontent.com/gliderlabs/docker-alpine/master/builder/scripts/mkimage-alpine.bash && \ - chmod +x \ - /mkimage-alpine.bash && \ - ./mkimage-alpine.bash && \ - mkdir /root-out && \ - tar xf \ - /rootfs.tar.xz -C \ - /root-out && \ + mkdir -p "$ROOTFS/etc/apk" && \ + { \ + echo "$MIRROR/$REL/main"; \ + echo "$MIRROR/$REL/community"; \ + } > "$ROOTFS/etc/apk/repositories" && \ + apk --root "$ROOTFS" --no-cache --keys-dir /etc/apk/keys add --arch $ARCH --initdb ${PACKAGES//,/ } && \ sed -i -e 's/^root::/root:!:/' /root-out/etc/shadow # set version for s6 overlay diff --git a/Dockerfile.armhf b/Dockerfile.armhf index d77ccb0..5177e53 100644 --- a/Dockerfile.armhf +++ b/Dockerfile.armhf @@ -1,8 +1,9 @@ # syntax=docker/dockerfile:1 -FROM alpine:3.17 as rootfs-stage +FROM alpine:3 as rootfs-stage # environment +ENV ROOTFS=/root-out ENV REL=edge ENV ARCH=armv7 ENV MIRROR=http://dl-cdn.alpinelinux.org/alpine @@ -10,29 +11,22 @@ ENV PACKAGES=alpine-baselayout,\ alpine-keys,\ apk-tools,\ busybox,\ -libc-utils,\ -xz +libc-utils # install packages RUN \ apk add --no-cache \ bash \ - curl \ - tzdata \ xz -# fetch builder script from gliderlabs +# build rootfs RUN \ - curl -o \ - /mkimage-alpine.bash -L \ - https://raw.githubusercontent.com/gliderlabs/docker-alpine/master/builder/scripts/mkimage-alpine.bash && \ - chmod +x \ - /mkimage-alpine.bash && \ - ./mkimage-alpine.bash && \ - mkdir /root-out && \ - tar xf \ - /rootfs.tar.xz -C \ - /root-out && \ + mkdir -p "$ROOTFS/etc/apk" && \ + { \ + echo "$MIRROR/$REL/main"; \ + echo "$MIRROR/$REL/community"; \ + } > "$ROOTFS/etc/apk/repositories" && \ + apk --root "$ROOTFS" --no-cache --keys-dir /etc/apk/keys add --arch $ARCH --initdb ${PACKAGES//,/ } && \ sed -i -e 's/^root::/root:!:/' /root-out/etc/shadow # set version for s6 overlay diff --git a/root/etc/s6-overlay/s6-rc.d/init-adduser/run b/root/etc/s6-overlay/s6-rc.d/init-adduser/run index a619c4f..2a0c256 100755 --- a/root/etc/s6-overlay/s6-rc.d/init-adduser/run +++ b/root/etc/s6-overlay/s6-rc.d/init-adduser/run @@ -52,6 +52,6 @@ Apps will not behave correctly without this sleep infinity fi -chown abc:abc /app -chown abc:abc /config -chown abc:abc /defaults +lsiown abc:abc /app +lsiown abc:abc /config +lsiown abc:abc /defaults