From 1c0edcaf2b4ed5f22d679f20633e5c61602a4b94 Mon Sep 17 00:00:00 2001 From: j842 Date: Mon, 26 May 2025 15:32:33 +1200 Subject: [PATCH] Broken --- Dockerfile | 66 ++++++++++++++++++------------------------------------ 1 file changed, 22 insertions(+), 44 deletions(-) diff --git a/Dockerfile b/Dockerfile index 729a3a8..a162e1a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,8 +10,13 @@ ENV CFLAGS="-static -O2" \ CXXFLAGS="-static -O2" \ LDFLAGS="-static" +# Create non-root user +RUN adduser -D -u 1000 builder + # Install build dependencies -RUN apk add --no-cache \ +RUN echo "https://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories && \ + apk update && \ + apk add --no-cache \ build-base \ cmake \ ninja \ @@ -41,53 +46,25 @@ RUN apk add --no-cache \ libtool \ patch \ gawk \ - xz-dev - -# Build ncurses from source -RUN cd /tmp && \ - wget https://invisible-mirror.net/archives/ncurses/ncurses-6.4.tar.gz && \ - tar xf ncurses-6.4.tar.gz && \ - cd ncurses-6.4 && \ - ./configure --prefix=/usr \ - --without-shared \ - --with-normal \ - --enable-pc-files \ - --with-pkg-config-libdir=/usr/lib/pkgconfig \ - --enable-widec \ - --disable-database \ - --with-fallbacks=linux \ - --with-panel \ - --with-panel-libs && \ - make -j$(nproc) && \ - make install && \ - cd .. && \ - rm -rf ncurses-6.4* - -# Build crosstool-ng -RUN cd /tmp && \ - wget https://github.com/crosstool-ng/crosstool-ng/releases/download/crosstool-ng-1.25.0/crosstool-ng-1.25.0.tar.xz && \ - tar xf crosstool-ng-1.25.0.tar.xz && \ - cd crosstool-ng-1.25.0 && \ - export CPPFLAGS="-I/usr/include/ncursesw" && \ - ./configure --prefix=/usr && \ - make -j$(nproc) && \ - make install && \ - cd .. && \ - rm -rf crosstool-ng-1.25.0* + xz-dev \ + crosstool-ng # Create crosstool-ng config RUN mkdir -p /tmp/ct-ng && \ + chown -R builder:builder /tmp/ct-ng && \ cd /tmp/ct-ng && \ - ct-ng aarch64-unknown-linux-musl && \ - sed -i 's/CT_MUSL_VERSION="1.2.4"/CT_MUSL_VERSION="1.2.4"/' .config && \ - sed -i 's/CT_GCC_VERSION="13.1.0"/CT_GCC_VERSION="13.1.0"/' .config && \ - sed -i 's/CT_BINUTILS_VERSION="2.41"/CT_BINUTILS_VERSION="2.41"/' .config && \ - sed -i 's/CT_LINUX_VERSION="6.1.28"/CT_LINUX_VERSION="6.1.28"/' .config && \ - sed -i 's/CT_PARALLEL_JOBS=0/CT_PARALLEL_JOBS=$(nproc)/' .config + su builder -c "ct-ng aarch64-unknown-linux-musl" && \ + su builder -c "sed -i 's/CT_MUSL_VERSION=\"1.2.4\"/CT_MUSL_VERSION=\"1.2.4\"/' .config" && \ + su builder -c "sed -i 's/CT_GCC_VERSION=\"13.1.0\"/CT_GCC_VERSION=\"13.1.0\"/' .config" && \ + su builder -c "sed -i 's/CT_BINUTILS_VERSION=\"2.41\"/CT_BINUTILS_VERSION=\"2.41\"/' .config" && \ + su builder -c "sed -i 's/CT_LINUX_VERSION=\"6.1.28\"/CT_LINUX_VERSION=\"6.1.28\"/' .config" && \ + su builder -c "sed -i 's/CT_PARALLEL_JOBS=0/CT_PARALLEL_JOBS=$(nproc)/' .config" && \ + su builder -c "echo 'CT_EXTRA_CFLAGS_FOR_BUILD=\"-D_FILE_OFFSET_BITS=64\"' >> .config" && \ + su builder -c "echo 'CT_EXTRA_CFLAGS_FOR_HOST=\"-D_FILE_OFFSET_BITS=64\"' >> .config" # Build the toolchain RUN cd /tmp/ct-ng && \ - ct-ng build + su builder -c "unset CFLAGS CXXFLAGS LDFLAGS && ct-ng build" # Install the toolchain RUN mkdir -p /opt/cross && \ @@ -150,7 +127,9 @@ RUN strip --strip-unneeded /usr/local/lib/*.a FROM alpine:3.19 # Install core toolchain for building apps -RUN apk add --no-cache \ +RUN echo "https://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories && \ + apk update && \ + apk add --no-cache \ build-base \ cmake \ ninja \ @@ -163,8 +142,7 @@ RUN apk add --no-cache \ linux-headers \ ccache \ mold \ - ncurses-dev \ - ncurses-terminfo-base + crosstool-ng # Configure mold as the default linker ENV LD=mold