stargazing/cosmo-muon/Dockerfile

51 lines
1.8 KiB
Text
Raw Normal View History

2022-10-04 04:55:30 -07:00
# MAIN: https://muon.build/
# REPO: https://git.sr.ht/~lattis/muon
FROM localhost/notwa-util AS downloader
2022-10-25 19:42:16 -07:00
ARG MUON_COMMIT=cdb84257b50ebdeddd1ea696fe433e4a3316c8a9
ARG MUON_SHA256=c8104d857ccaea09ddb6e9a83c73b4a061550c1257f7673c904a137d8a716f04
2022-10-04 04:55:30 -07:00
RUN --mount=type=cache,id=common,target=/media/common,sharing=locked \
--mount=type=tmpfs,target=/tmp : \
2022-10-11 11:18:16 -07:00
&& acquire from=sourcehut repo=lattis/muon dest=/muon env=MUON \
2022-10-04 04:55:30 -07:00
;
FROM localhost/cosmo-base AS builder
2022-10-04 04:55:30 -07:00
RUN apk add --no-cache ninja
COPY --chmod=0755 --from=localhost/notwa-util /nu/cosmocc /usr/bin/
ENV CC=cosmocc CFLAGS="-Os -g -fdiagnostics-color=always"
# TODO: why is this test failing?
# c compiler: supports argument '-Wundef': NO
COPY --from=downloader /muon /muon
WORKDIR /muon
RUN : \
&& tar zxf /cosmopolitan/dist/headers.tar.gz -C /cosmopolitan \
&& ./bootstrap.sh build \
;
COPY --chmod=0755 --from=localhost/notwa-util /nu/shed /usr/bin/
RUN : \
# forcibly disable handling of 32-bit ELF files (we lack the headers) \
&& shed src/platform/posix/rpath_fixer.c \
'/\bcase ELFCLASS32:/,/\bbreak;/d' \
's@.*Elf32.*@/* & */@' \
# use cosmopolitan linenoise instead of bestline \
&& echo >subprojects/bestline/bestline.c \
&& printf '%s\n' >subprojects/bestline/bestline.h \
'#include "third_party/linenoise/linenoise.h"' \
'#define bestlineHistoryAdd linenoiseHistoryAdd' \
'#define bestlineHistoryFree linenoiseHistoryFree' \
'#define bestlineWithHistory linenoiseWithHistory' \
\
&& build/muon setup -Dstatic=true build \
&& ninja -j2 -C build \
&& cd build \
&& mv muon muon.com.dbg \
&& objcopy -S -O binary muon.com.dbg muon.com \
;
FROM localhost/rescue AS runner
2022-10-04 04:55:30 -07:00
COPY --chmod=0755 --from=builder /muon/build/muon.com /muon/build/muon.com.dbg /bin/
ENTRYPOINT ["/bin/ape", "/bin/muon.com"]