Skip to content

Commit 121bf4f

Browse files
authored
feat: Add Docker builder (#82)
Adds: - Basic Dockerfile that builds diagon and exposes the binary in a small-ish image (~80MB). - README section for building and running the image.
1 parent 5dc33a1 commit 121bf4f

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

Dockerfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
FROM ubuntu:24.04 AS builder
2+
3+
ARG ANTLR_VERSION=4.13.2
4+
ENV ANTLR_VERSION=$ANTLR_VERSION
5+
6+
RUN apt update && \
7+
apt install -y make libboost-graph-dev cmake default-jdk git g++ wget
8+
COPY . /Diagon
9+
RUN mkdir -p Diagon/build && \
10+
cd Diagon/build && \
11+
cmake .. -DCMAKE_BUILD_TYPE=Release && \
12+
wget -O antlr.jar https://www.antlr.org/download/antlr-$ANTLR_VERSION-complete.jar && \
13+
make -j install
14+
15+
FROM ubuntu:24.04 AS runner
16+
COPY --from=builder /usr/local/bin/diagon /usr/local/bin/diagon
17+
RUN useradd -u 1101 diagon
18+
USER 1101
19+
ENTRYPOINT [ "diagon" ]

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -647,6 +647,20 @@ cmake .. -DCMAKE_BUILD_TYPE=Release
647647
make -j
648648
sudo make install
649649
```
650+
651+
## Build in Docker
652+
653+
If you have Docker installed, the repository includes a Dockerfile for convenient building:
654+
```sh
655+
docker build -t diagon .
656+
```
657+
658+
Once built, the image can be invoked like the binary:
659+
```sh
660+
docker run diagon Math -- "f(x) = 1 + x / (1 + x)"
661+
662+
echo "f(x) = 1 + x / (1 + x)" | docker run -i diagon Math
663+
```
650664
651665
# Packaging status
652666

0 commit comments

Comments
 (0)