Skip to content

Commit

Permalink
feat: Add Docker builder (#82)
Browse files Browse the repository at this point in the history
Adds:
- Basic Dockerfile that builds diagon and exposes the binary in a small-ish image (~80MB).
- README section for building and running the image.
  • Loading branch information
praktiskt authored Nov 22, 2024
1 parent 5dc33a1 commit 121bf4f
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
19 changes: 19 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM ubuntu:24.04 AS builder

ARG ANTLR_VERSION=4.13.2
ENV ANTLR_VERSION=$ANTLR_VERSION

RUN apt update && \
apt install -y make libboost-graph-dev cmake default-jdk git g++ wget
COPY . /Diagon
RUN mkdir -p Diagon/build && \
cd Diagon/build && \
cmake .. -DCMAKE_BUILD_TYPE=Release && \
wget -O antlr.jar https://www.antlr.org/download/antlr-$ANTLR_VERSION-complete.jar && \
make -j install

FROM ubuntu:24.04 AS runner
COPY --from=builder /usr/local/bin/diagon /usr/local/bin/diagon
RUN useradd -u 1101 diagon
USER 1101
ENTRYPOINT [ "diagon" ]
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,20 @@ cmake .. -DCMAKE_BUILD_TYPE=Release
make -j
sudo make install
```

## Build in Docker

If you have Docker installed, the repository includes a Dockerfile for convenient building:
```sh
docker build -t diagon .
```

Once built, the image can be invoked like the binary:
```sh
docker run diagon Math -- "f(x) = 1 + x / (1 + x)"

echo "f(x) = 1 + x / (1 + x)" | docker run -i diagon Math
```
# Packaging status

Expand Down

0 comments on commit 121bf4f

Please sign in to comment.