Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker image for build and use the CLI tool directly #59

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# D language specific
.dub/
*.o
*.obj
*.lst
*.a
*.lib
*.so
*.dylib
*.dll
*.exe

# Build and output directories
build/
bin/
obj/

# Editor and IDE files
.vscode/
.idea/
*.swp
*~

# Version control
.git/
.gitignore
.gitattributes

# Documentation and temporary files
docs/
*.html
*.pdf
*.log
*.tmp

# Test files
test/
unittest/
*_test.*

# Dependencies that should be fetched during build
dub.selections.json

# OS specific files
.DS_Store
Thumbs.db

# Project specific
*.o.d
__test__*
.dub
dub.selections.json
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"]
8 changes: 2 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,8 @@ test: lit

lit/markdown/source:
@if [ ! -s lit/markdown/source ]; then \
if [ ! -s .git ]; then \
git clone https://github.com/zyedidia/dmarkdown lit/markdown; \
else \
git submodule init; \
git submodule update; \
fi \
echo "Missing lit/markdown/source"; \
exit 1; \
fi;

clean:
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:
4 changes: 0 additions & 4 deletions dub.selections.json

This file was deleted.