FROM localhost/cosmo-bootstrap AS builder # install the basics (no executable binaries besides ape.elf) RUN : \ && . ./env \ && mkdir dist "dist/$flavor" "dist/$flavor/public" \ && echo /dist >>.gitignore \ && ./expand cp -t "dist/$flavor" \ a//ape-copy-self.o a//ape-no-modify-self.o a//ape.elf \ a//ape.lds a//ape.macho a//ape.o \ o//cosmopolitan.a o//libc/crt/crt.o o/cosmopolitan.h \ && cp -t "dist/$flavor/public" "o/$mode/ape/public/ape.lds" \ \ && install -m0755 "dist/$flavor/ape.elf" /usr/bin/ape \ && find libc -name '*.h' >headers.txt \ && ./expand tar zcf dist/headers.tar.gz -T headers.txt \ ape/config.h libc/integral T//gdtoa/gdtoa.h \ T//getopt/getopt.h T//linenoise/linenoise.h T//musl/crypt.h \ T//musl/fnmatch.h T//musl/lockf.h T//musl/passwd.h \ T//musl/rand48.h T//musl/tempnam.h T//regex/regex.h \ T//zlib/zconf.h T//zlib/zlib.h \ ; # install the rest FROM builder AS distrib RUN --mount=type=tmpfs,target=/tmp : \ && . ./env \ && find o -name '*.sym' -delete \ && dedupe o/third_party/gcc /distrib/gcc/ \ bin/x86_64-linux-musl-gcc \ bin/x86_64-linux-musl-g++ \ bin/x86_64-linux-musl-ld.bfd \ && dedupe dist /distrib/dist/ "$flavor/cosmopolitan.h" \ && mkdir /tmp/bin \ # discover .com files by uncommenting this command: \ #&& find o -name '*.com' ! -type d -exec printf '%s\n' cp -t /tmp/bin {} + | sort && exit 1 \ && ./expand cp -t /tmp/bin \ e//unbourne.com t//awk/awk.com t//make/make.com \ t//sed/sed.com t//unzip/unzip.com t//zip/zip.com \ b//ar.com b//assimilate.com b//cocmd.com \ b//compile.com b//cp.com b//echo.com \ b//fixupobj.com b//gzip.com b//mkdeps.com \ b//mkdir.com b//package.com b//pwd.com \ b//rm.com b//rollup.com b//symtab.com \ b//touch.com b//unbundle.com b//zipobj.com \ && dedupe /tmp/bin /distrib/bin/ \ #&& ln -s "../dist/$flavor/ape.elf" /distrib/bin/ape \ && cp "dist/$flavor/ape.elf" /distrib/bin/ape \ && cp /cosmopolitan/env /distrib/env \ ; FROM alpine:3.16 AS runner COPY --from=distrib /distrib /cosmopolitan ENV PATH="/cosmopolitan/bin:/cosmopolitan/gcc/bin/:/cosmopolitan/gcc/x86_64-linux-musl/bin/:$PATH" # FIXME: #ARG COSMO_FLAVOR #ENV COSMO_DIST="/cosmopolitan/dist/$COSMO_FLAVOR"