Skip to content

Commit 782c93c

Browse files
authored
Bring back the ability to build Scrapscript in Docker (#145)
1 parent bba66bd commit 782c93c

File tree

4 files changed

+43
-1
lines changed

4 files changed

+43
-1
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ jobs:
7373
push: true
7474
tags: ${{ steps.meta.outputs.tags }}
7575
labels: ${{ steps.meta.outputs.labels }}
76+
target: main
7677
deploy:
7778
runs-on: ubuntu-latest
7879
if: |

Dockerfile

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,34 @@
1-
FROM caddy
1+
FROM caddy as web
22
COPY . .
33
RUN echo ":8000" > /etc/caddy/Caddyfile
44
RUN echo "rewrite /repl /repl.html" >> /etc/caddy/Caddyfile
55
RUN echo "rewrite /compilerepl /compilerepl.html" >> /etc/caddy/Caddyfile
66
RUN echo "log" >> /etc/caddy/Caddyfile
77
RUN echo "file_server" >> /etc/caddy/Caddyfile
8+
9+
FROM alpine:latest as build
10+
RUN printf -- '-m\nscrapscript\n...' > .args
11+
RUN wget https://cosmo.zip/pub/cosmos/bin/assimilate
12+
RUN wget https://cosmo.zip/pub/cosmos/bin/ape-x86_64.elf
13+
RUN wget https://cosmo.zip/pub/cosmos/bin/python
14+
RUN wget https://cosmo.zip/pub/cosmos/bin/zip
15+
RUN chmod +x assimilate
16+
RUN chmod +x ape-x86_64.elf
17+
RUN chmod +x python
18+
RUN chmod +x zip
19+
RUN mkdir Lib
20+
COPY scrapscript.py Lib/
21+
COPY compiler.py Lib/
22+
COPY runtime.c Lib/
23+
COPY cli.c Lib/
24+
RUN ./ape-x86_64.elf ./python -m compileall -b Lib/scrapscript.py Lib/compiler.py
25+
RUN mv python scrapscript.com
26+
RUN ./ape-x86_64.elf ./zip -r scrapscript.com Lib .args
27+
RUN ./ape-x86_64.elf ./assimilate ./scrapscript.com
28+
RUN echo "Testing..."
29+
RUN ./scrapscript.com apply "1+2"
30+
31+
# Set up the container
32+
FROM scratch as main
33+
COPY --from=build scrapscript.com .
34+
ENTRYPOINT ["./scrapscript.com"]

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,19 @@ or with [Cosmopolitan](https://justine.lol/cosmopolitan/index.html):
4040
(if you have an exec format error and use Zsh, either upgrade Zsh or prefix
4141
with `sh`)
4242

43+
or with Docker:
44+
45+
```bash
46+
# With a file (mount your local directory)
47+
docker run --mount type=bind,source="$(pwd)",target=/mnt -i -t ghcr.io/tekknolagi/scrapscript:trunk eval /mnt/examples/0_home/factorial.scrap
48+
49+
# With a string literal
50+
docker run -i -t ghcr.io/tekknolagi/scrapscript:trunk apply "1 + 2"
51+
52+
# With a REPL
53+
docker run -i -t ghcr.io/tekknolagi/scrapscript:trunk repl
54+
```
55+
4356
### The experimental compiler:
4457

4558
#### Normal ELF

fly.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ app = "scrapscript"
77
primary_region = "ewr"
88

99
[build]
10+
build-target = "web"
1011

1112
[http_service]
1213
internal_port = 8000

0 commit comments

Comments
 (0)