From 6aa28a420cb94aba83d22246b778070322049700 Mon Sep 17 00:00:00 2001 From: Max Bernstein Date: Thu, 7 Dec 2023 01:03:41 -0500 Subject: [PATCH] Add ability to build scrapscript.com as one binary --- .args | 3 +++ Dockerfile | 10 ++++++---- build-com | 20 ++++++++++++++++++++ 3 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 .args create mode 100755 build-com diff --git a/.args b/.args new file mode 100644 index 00000000..88f32864 --- /dev/null +++ b/.args @@ -0,0 +1,3 @@ +-m +scrapscript +... diff --git a/Dockerfile b/Dockerfile index 6d4ebc94..90df097d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,15 +7,17 @@ WORKDIR cosmo RUN unzip ../$COSMO bin/ape.elf bin/assimilate bin/bash bin/python bin/zip RUN mkdir Lib COPY scrapscript.py Lib +COPY .args . RUN bin/ape.elf bin/python -m compileall Lib RUN mv Lib/__pycache__/scrapscript*.pyc Lib/scrapscript.pyc RUN rm Lib/scrapscript.py -RUN sh bin/zip -A -r bin/python Lib -RUN bin/ape.elf bin/assimilate bin/python +RUN cp bin/python bin/scrapscript.com +RUN sh bin/zip -A -r bin/scrapscript.com Lib .args +RUN bin/ape.elf bin/assimilate bin/scrapscript.com # Set up the container FROM scratch -COPY --from=build /cosmo/bin/python . +COPY --from=build /cosmo/bin/scrapscript.com . EXPOSE 8000 -ENTRYPOINT ["./python", "-m", "scrapscript"] +ENTRYPOINT ["./scrapscript.com"] CMD ["repl"] diff --git a/build-com b/build-com new file mode 100755 index 00000000..064b4547 --- /dev/null +++ b/build-com @@ -0,0 +1,20 @@ +#!/bin/sh +set -eux +PREV="$(pwd)" +DIR="$(mktemp -d)" +cp scrapscript.py "$DIR" +cp .args "$DIR" +cd "$DIR" +wget https://cosmo.zip/pub/cosmos/bin/python +wget https://cosmo.zip/pub/cosmos/bin/zip +chmod +x python +chmod +x zip +./python -m compileall scrapscript.py +mkdir Lib +cp __pycache__/scrapscript.cpython-311.pyc Lib/scrapscript.pyc +cp python scrapscript.com +./zip -r scrapscript.com Lib .args +echo "Testing..." +./scrapscript.com apply "1+2" +cd "$PREV" +cp "$DIR"/scrapscript.com .