Skip to content

Commit

Permalink
Setup docker compose for anyone to build and release locally
Browse files Browse the repository at this point in the history
  • Loading branch information
Bingnan Liu committed Dec 30, 2024
1 parent 3494e48 commit 875b5e3
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 0 deletions.
38 changes: 38 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Use Ubuntu as base image
FROM ubuntu:latest

# Avoid prompts from apt
ENV DEBIAN_FRONTEND=noninteractive

# Install necessary dependencies
RUN apt-get update && apt-get install -y \
curl \
gpg \
xz-utils \
gcc \
make \
&& rm -rf /var/lib/apt/lists/*

# Install DMD compiler
RUN curl -fsS https://dlang.org/install.sh | bash -s dmd \
&& ln -s /root/dlang/dmd-*/linux/bin64/dmd /usr/local/bin/dmd \
&& ln -s /root/dlang/dmd-*/linux/bin64/dub /usr/local/bin/dub

# Set working directory
WORKDIR /app

# Copy only dependency files first to leverage Docker cache
COPY dub.sdl ./
COPY lit/markdown/dub.json ./lit/markdown/

# Install dependencies
RUN dub fetch --cache=local

# Copy the rest of the project
COPY . .

# Build the project
RUN make

# Set the entrypoint to the binary
ENTRYPOINT ["/app/bin/lit"]
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export LD_LIBRARY_PATH=/home/linuxbrew/.linuxbrew/lib

release: lit/markdown/source d-files
@mkdir -p bin
dub build --build=release
Expand Down
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,27 @@ You can also find this program in `examples/hello.lit`.
| [32 bit Linux](https://zyedidia.github.io/literate/binaries/literate-linux32.tar.gz) |
| [Arm Linux](https://zyedidia.github.io/literate/binaries/literate-linux-arm.tar.gz) |

### Docker

Docker images are prepared so users could build Literate easily on their local machine by running:
```sh
cd Literate # go to the root directory of Literate
git submodule update --init --recursive
docker compose build
```

Then you can run the binary by mounting your source code into the docker container:
```sh
SOURCE_DIR=/path/to/your/source
OUTPUT_DIR=/path/to/your/output/dir
docker run --rm -it -v $SOURCE_DIR:/source docker.io/library/literate:latest $SOURCE_DIR/code.lit --out-dir $OUTPUT_DIR
```

You can also copy the built binary out by
```sh
docker run --rm -it -v ./bin:/tmp/bin --entrypoint bash docker.io/library/literate:latest -c 'cp /app/bin/lit /tmp/bin'
```

### Building from Source

#### Mac
Expand Down
7 changes: 7 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
services:
app-release:
build: .
image: literate:latest

volumes:
build-bin-output:

0 comments on commit 875b5e3

Please sign in to comment.