FROM scratch AS base ENV VERSION=2.6.4 ENV SRC_HASH=e87aae032bf07c26f85ac0ed3250998c37621d95f8bd748b31f15b33c45ee995 ENV SRC_FILE=flex-${VERSION}.tar.gz ENV SRC_SITE=https://github.com/westes/flex/releases/download/v${VERSION}/${SRC_FILE} FROM base AS fetch ADD --checksum=sha256:${SRC_HASH} ${SRC_SITE} . FROM fetch AS build COPY --from=stagex/busybox . / COPY --from=stagex/perl . / COPY --from=stagex/gcc . / COPY --from=stagex/binutils . / COPY --from=stagex/make . / COPY --from=stagex/m4 . / COPY --from=stagex/libtool . / COPY --from=stagex/autoconf . / COPY --from=stagex/automake . / COPY --from=stagex/bison . / COPY --from=stagex/gettext . / COPY --from=stagex/musl . / RUN tar -xzf ${SRC_FILE} WORKDIR /flex-${VERSION} RUN --network=none <<-EOF set -eux ./autogen.sh ./configure \ --build=x86_64-unknown-linux-musl \ --host=x86_64-unknown-linux-musl \ --prefix=/usr \ --bindir=/usr/bin \ --mandir=/usr/share/man \ --infodir=/usr/share/info make -j "$(nproc)" LDFLAGS=-static EOF FROM build AS install RUN --network=none make DESTDIR=/rootfs install FROM stagex/filesystem AS package COPY --from=install /rootfs/. /