From cd7c50e79e8652e9329584f3d6924e4e8f074b9a Mon Sep 17 00:00:00 2001 From: "Lance R. Vick" Date: Thu, 9 Nov 2023 02:13:20 -0800 Subject: [PATCH] add initial bash and busybox --- Makefile | 11 +++++++ packages/bash/Dockerfile | 16 ++++++++++ packages/busybox/Dockerfile | 63 +++++++++++++++++++++++++++++++++++++ 3 files changed, 90 insertions(+) create mode 100644 Makefile create mode 100644 packages/bash/Dockerfile create mode 100644 packages/busybox/Dockerfile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..77b75e3 --- /dev/null +++ b/Makefile @@ -0,0 +1,11 @@ +out/gcc.oci.tgz: + docker build -f packages/gcc/Dockerfile -t ocirep/gcc . + +out/bash.oci.tgz: + docker build -f packages/bash/Dockerfile -t ocirep/bash . + +out/busybox.oci.tgz: + docker build -f packages/busybox/Dockerfile -t ocirep/busybox . + +out/go.oci.tgz: + docker build -f packages/go/Dockerfile -t ocirep/go . diff --git a/packages/bash/Dockerfile b/packages/bash/Dockerfile new file mode 100644 index 0000000..bad27cd --- /dev/null +++ b/packages/bash/Dockerfile @@ -0,0 +1,16 @@ +ARG GCC_IMAGE=library/gcc@sha256:ca38f292fe1ad0933f0122a657f9c644ed1f0a9e1aa336abcc83d420ad487e28 + +FROM ${GCC_IMAGE} as build +ENV SOURCE_SITE=https://ftp.gnu.org/gnu/bash +ENV SOURCE_VERSION=5.2.15 +ENV SOURCE_HASH=13720965b5f4fc3a0d4b61dd37e7565c741da9a5be24edc2ae00182fc1b3588c +RUN wget ${SOURCE_SITE}/bash-${SOURCE_VERSION}.tar.gz +RUN echo "${SOURCE_HASH} bash-${SOURCE_VERSION}.tar.gz" | sha256sum -c +RUN tar -xzf bash-${SOURCE_VERSION}.tar.gz +RUN \ + cd bash-${SOURCE_VERSION} \ + && ./configure --enable-static-link \ + && make install + +FROM scratch +COPY --from=build /usr/local/bin/bash / diff --git a/packages/busybox/Dockerfile b/packages/busybox/Dockerfile new file mode 100644 index 0000000..bd22705 --- /dev/null +++ b/packages/busybox/Dockerfile @@ -0,0 +1,63 @@ +ARG GCC_IMAGE=library/gcc@sha256:ca38f292fe1ad0933f0122a657f9c644ed1f0a9e1aa336abcc83d420ad487e28 + +FROM ${GCC_IMAGE} as build +ENV SOURCE_SITE=https://busybox.net/downloads +ENV SOURCE_VERSION=1.36.1 +ENV SOURCE_HASH=b8cc24c9574d809e7279c3be349795c5d5ceb6fdf19ca709f80cde50e47de314 +RUN wget ${SOURCE_SITE}/busybox-${SOURCE_VERSION}.tar.bz2 +RUN echo "${SOURCE_HASH} busybox-${SOURCE_VERSION}.tar.bz2" | sha256sum -c +RUN tar -xjf busybox-${SOURCE_VERSION}.tar.bz2 +WORKDIR busybox-${SOURCE_VERSION} +RUN set -eux; \ + setConfs=' \ + CONFIG_AR=y \ + CONFIG_FEATURE_AR_CREATE=y \ + CONFIG_FEATURE_AR_LONG_FILENAMES=y \ + CONFIG_LAST_SUPPORTED_WCHAR=0 \ + CONFIG_STATIC=y \ + '; \ + unsetConfs=' \ + CONFIG_FEATURE_SYNC_FANCY \ + CONFIG_FEATURE_HAVE_RPC \ + CONFIG_FEATURE_INETD_RPC \ + CONFIG_FEATURE_UTMP \ + CONFIG_FEATURE_WTMP \ + '; \ + make defconfig; \ + for conf in $unsetConfs; do \ + sed -i \ + -e "s!^$conf=.*\$!# $conf is not set!" \ + .config; \ + done; \ + for confV in $setConfs; do \ + conf="${confV%=*}"; \ + sed -i \ + -e "s!^$conf=.*\$!$confV!" \ + -e "s!^# $conf is not set\$!$confV!" \ + .config; \ + if ! grep -q "^$confV\$" .config; then \ + echo "$confV" >> .config; \ + fi; \ + done; \ + make oldconfig; \ + for conf in $unsetConfs; do \ + ! grep -q "^$conf=" .config; \ + done; \ + for confV in $setConfs; do \ + grep -q "^$confV\$" .config; \ + done + +RUN make +RUN cp ./busybox / + +FROM scratch +COPY --from=build /busybox . +RUN ["/busybox","mkdir","/bin"] +RUN ["/busybox","--install","-s","/bin"] +RUN echo "nogroup:*:100:nobody" > /etc/group +RUN echo "nobody:*:100:100:::" > /etc/passwd +RUN mkdir /tmp +RUN chown -R 100:100 /tmp +WORKDIR /tmp +USER 100:100 +ENTRYPOINT ["/bin/sh"]