Skip to content

Commit

Permalink
Bring back the ability to build Scrapscript in Docker (#145)
Browse files Browse the repository at this point in the history
  • Loading branch information
tekknolagi authored Jun 6, 2024
1 parent bba66bd commit 782c93c
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ jobs:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
target: main
deploy:
runs-on: ubuntu-latest
if: |
Expand Down
29 changes: 28 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,34 @@
FROM caddy
FROM caddy as web
COPY . .
RUN echo ":8000" > /etc/caddy/Caddyfile
RUN echo "rewrite /repl /repl.html" >> /etc/caddy/Caddyfile
RUN echo "rewrite /compilerepl /compilerepl.html" >> /etc/caddy/Caddyfile
RUN echo "log" >> /etc/caddy/Caddyfile
RUN echo "file_server" >> /etc/caddy/Caddyfile

FROM alpine:latest as build
RUN printf -- '-m\nscrapscript\n...' > .args
RUN wget https://cosmo.zip/pub/cosmos/bin/assimilate
RUN wget https://cosmo.zip/pub/cosmos/bin/ape-x86_64.elf
RUN wget https://cosmo.zip/pub/cosmos/bin/python
RUN wget https://cosmo.zip/pub/cosmos/bin/zip
RUN chmod +x assimilate
RUN chmod +x ape-x86_64.elf
RUN chmod +x python
RUN chmod +x zip
RUN mkdir Lib
COPY scrapscript.py Lib/
COPY compiler.py Lib/
COPY runtime.c Lib/
COPY cli.c Lib/
RUN ./ape-x86_64.elf ./python -m compileall -b Lib/scrapscript.py Lib/compiler.py
RUN mv python scrapscript.com
RUN ./ape-x86_64.elf ./zip -r scrapscript.com Lib .args
RUN ./ape-x86_64.elf ./assimilate ./scrapscript.com
RUN echo "Testing..."
RUN ./scrapscript.com apply "1+2"

# Set up the container
FROM scratch as main
COPY --from=build scrapscript.com .
ENTRYPOINT ["./scrapscript.com"]
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,19 @@ or with [Cosmopolitan](https://justine.lol/cosmopolitan/index.html):
(if you have an exec format error and use Zsh, either upgrade Zsh or prefix
with `sh`)

or with Docker:

```bash
# With a file (mount your local directory)
docker run --mount type=bind,source="$(pwd)",target=/mnt -i -t ghcr.io/tekknolagi/scrapscript:trunk eval /mnt/examples/0_home/factorial.scrap

# With a string literal
docker run -i -t ghcr.io/tekknolagi/scrapscript:trunk apply "1 + 2"

# With a REPL
docker run -i -t ghcr.io/tekknolagi/scrapscript:trunk repl
```

### The experimental compiler:

#### Normal ELF
Expand Down
1 change: 1 addition & 0 deletions fly.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ app = "scrapscript"
primary_region = "ewr"

[build]
build-target = "web"

[http_service]
internal_port = 8000
Expand Down

0 comments on commit 782c93c

Please sign in to comment.