diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..6455eb2 --- /dev/null +++ b/.dockerignore @@ -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 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..df26d18 --- /dev/null +++ b/Dockerfile @@ -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"] \ No newline at end of file diff --git a/Makefile b/Makefile index a4afeef..5d1fe46 100644 --- a/Makefile +++ b/Makefile @@ -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: diff --git a/README.md b/README.md index 6d840c8..6f7c8aa 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..4138d5b --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,7 @@ +services: + app-release: + build: . + image: literate:latest + +volumes: + build-bin-output: \ No newline at end of file diff --git a/dub.selections.json b/dub.selections.json deleted file mode 100644 index 8d54351..0000000 --- a/dub.selections.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "fileVersion": 1, - "versions": {} -}