Skip to content

Commit

Permalink
Add ability to build scrapscript.com as one binary
Browse files Browse the repository at this point in the history
  • Loading branch information
tekknolagi committed Dec 7, 2023
1 parent fd08530 commit 6aa28a4
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .args
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-m
scrapscript
...
10 changes: 6 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
20 changes: 20 additions & 0 deletions build-com
Original file line number Diff line number Diff line change
@@ -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 .

0 comments on commit 6aa28a4

Please sign in to comment.