├── .tagignore ├── Dockerfile ├── LICENSE ├── README.md ├── build ├── entrypoint.sh └── gather_tags /.tagignore: -------------------------------------------------------------------------------- 1 | ^2.000$ 2 | ^2.001$ 3 | ^2.002$ 4 | ^2.003$ 5 | ^2.004$ 6 | ^2.005$ 7 | ^2.006$ 8 | ^2.007$ 9 | ^2.008$ 10 | ^2.009$ 11 | ^2.010$ 12 | ^2.011$ 13 | ^2.012$ 14 | ^2.013$ 15 | ^2.014$ 16 | ^2.015$ 17 | ^2.016$ 18 | ^2.017$ 19 | ^2.018$ 20 | ^2.019$ 21 | ^2.020$ 22 | ^2.021$ 23 | ^2.022$ 24 | ^2.023$ 25 | ^2.025$ 26 | ^2.026$ 27 | ^2.027$ 28 | ^2.028$ 29 | ^2.029$ 30 | ^2.030$ 31 | ^2.031$ 32 | ^2.032$ 33 | ^2.033$ 34 | ^2.034$ 35 | ^2.035$ 36 | ^2.036$ 37 | ^2.037$ 38 | ^2.038$ 39 | ^2.039$ 40 | ^2.040$ 41 | ^2.041$ 42 | ^2.042$ 43 | ^2.043$ 44 | ^2.044$ 45 | ^2.045$ 46 | ^2.046$ 47 | ^2.047$ 48 | ^2.048$ 49 | ^2.049$ 50 | ^2.050$ 51 | ^2.051$ 52 | ^2.052$ 53 | ^2.053$ 54 | ^2.054$ 55 | ^2.055$ 56 | ^2.056$ 57 | ^2.057$ 58 | ^2.058$ 59 | ^2.059$ 60 | ^2.060$ 61 | ^2.061$ 62 | ^2.062$ 63 | ^2.063$ 64 | ^2.064$ 65 | ^2.065.0$ 66 | ^2.066.0$ 67 | ^2.066.1$ 68 | ^2.067.0$ 69 | ^2.067.1$ 70 | ^2.068.0$ -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:16.04 2 | 3 | MAINTAINER Stefan Rohe 4 | 5 | ENV \ 6 | COMPILER=dmd \ 7 | COMPILER_VERSION=2.080.0 8 | 9 | RUN apt-get update && apt-get install -y curl libcurl3 build-essential \ 10 | && curl -fsS -o /tmp/install.sh https://dlang.org/install.sh \ 11 | && bash /tmp/install.sh -p /dlang install "${COMPILER}-${COMPILER_VERSION}" \ 12 | && rm /tmp/install.sh \ 13 | && apt-get auto-remove -y curl build-essential \ 14 | && apt-get install -y gcc \ 15 | && rm -rf /var/cache/apt \ 16 | && rm -rf /dlang/${COMPILER}-*/linux/bin32 \ 17 | && rm -rf /dlang/${COMPILER}-*/linux/lib32 \ 18 | && rm -rf /dlang/${COMPILER}-*/html \ 19 | && rm -rf /dlang/dub-1.0.0/dub.tar.gz 20 | 21 | ENV \ 22 | PATH=/dlang/dub:/dlang/${COMPILER}-${COMPILER_VERSION}/linux/bin64:${PATH} \ 23 | LD_LIBRARY_PATH=/dlang/${COMPILER}-${COMPILER_VERSION}/linux/lib64 \ 24 | LIBRARY_PATH=/dlang/${COMPILER}-${COMPILER_VERSION}/linux/lib64 \ 25 | PS1="(${COMPILER}-${COMPILER_VERSION}) \\u@\\h:\\w\$" 26 | 27 | RUN cd /tmp \ 28 | && echo 'void main() {import std.stdio; stdout.writeln("it works"); }' > test.d \ 29 | && dmd test.d \ 30 | && ./test && rm test* 31 | 32 | WORKDIR /src 33 | 34 | ENV GOSU_VERSION 1.9 35 | RUN apt-get update \ 36 | && apt-get install -y --no-install-recommends ca-certificates wget \ 37 | && wget -O /usr/local/bin/gosu \ 38 | "https://github.com/tianon/gosu/releases/download/${GOSU_VERSION}/gosu-$(dpkg --print-architecture)" \ 39 | && wget -O /usr/local/bin/gosu.asc \ 40 | "https://github.com/tianon/gosu/releases/download/${GOSU_VERSION}/gosu-$(dpkg --print-architecture).asc" \ 41 | && export GNUPGHOME="$(mktemp -d)" \ 42 | && gpg --keyserver ha.pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 \ 43 | && gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu \ 44 | && rm -r "${GNUPGHOME}" /usr/local/bin/gosu.asc \ 45 | && chmod +x /usr/local/bin/gosu \ 46 | && gosu nobody true \ 47 | && apt-get auto-remove -y wget \ 48 | && rm -rf /var/lib/apt/lists/* \ 49 | && chmod 755 -R /dlang 50 | 51 | COPY entrypoint.sh / 52 | RUN chmod +x /entrypoint.sh 53 | 54 | ENTRYPOINT ["/entrypoint.sh"] 55 | CMD ["${COMPILER}"] 56 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 lindt 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Docker pulls](https://img.shields.io/docker/pulls/dlanguage/dmd.svg)](https://hub.docker.com/r/dlanguage/dmd/) 2 | [![Docker Build](https://img.shields.io/docker/automated/dlanguage/dmd.svg)](https://hub.docker.com/r/dlanguage/dmd/) 3 | [![Latest Tag](https://img.shields.io/github/tag/lindt/docker-dmd.svg)](https://hub.docker.com/r/dlanguage/dmd/) 4 | 5 | # docker-dmd 6 | 7 | Docker Image for DMD the Digital Mars [D](http://dlang.org) Compiler. 8 | 9 | ## Motivation 10 | 11 | Installation of a compiler sometimes is cumbersome. This Docker image should take this pain and allow you to easily switch between Versions of the same compiler and even different compilers. 12 | 13 | In case a native installation is required, `curl -fsS https://dlang.org/install.sh | bash -s dmd` could be used. 14 | 15 | ## Other Compilers 16 | 17 | Allows to use all major D Compilers without installation. 18 | 19 | | Compiler | Latest Tag | 20 | | -------- | ---------- | 21 | | DMD | [![Latest Tag](https://img.shields.io/github/tag/lindt/docker-dmd.svg)](https://hub.docker.com/r/dlanguage/dmd/) | 22 | | LDC | [![Latest Tag](https://img.shields.io/github/tag/lindt/docker-ldc.svg)](https://hub.docker.com/r/dlanguage/ldc/) | 23 | | GDC | [![Latest Tag](https://img.shields.io/github/tag/lindt/docker-gdc.svg)](https://hub.docker.com/r/dlanguage/gdc/) | 24 | 25 | ## Usage 26 | 27 | Place a `test.d` in your current directory. 28 | ``` 29 | import std.stdio; 30 | 31 | void main() { 32 | writeln("Hello, World!"); 33 | } 34 | ``` 35 | 36 | Then execute 37 | ```sh 38 | docker run --rm -ti -v $(pwd):/src dlanguage/dmd dmd -run test.d 39 | ``` 40 | 41 | This should plot: 42 | ``` 43 | Hello, World! 44 | ``` 45 | 46 | If you are too lazy to create a file, you can compile directly from stdin: 47 | 48 | ```sh 49 | echo 'void main(){import std.stdio; writeln("Hello World");}' | docker run --rm -i -v $(pwd):/src dlanguage/dmd dmd -run - 50 | ``` 51 | -------------------------------------------------------------------------------- /build: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | function delete_ignored_tags { 5 | for tag in $( sh gather_tags | grep -f .tagignore ); do 6 | if git show-ref --tags | grep "tags/${tag}$" 7 | then 8 | echo "Delete Tag ${tag}" 9 | git tag -d ${tag} && git push origin :refs/tags/${tag} 10 | fi 11 | done 12 | } 13 | 14 | function build_missing_tags { 15 | for tag in $( sh gather_tags | grep -v -f .tagignore ); do 16 | echo -n "Tag: ${tag} ... " 17 | if git show-ref --tags | grep "tags/${tag}$" &> /dev/null 18 | then 19 | echo 'is existing' 20 | else 21 | echo 'needs building' 22 | sed -i "s/COMPILER_VERSION=.*/COMPILER_VERSION=${tag}/" Dockerfile 23 | git add Dockerfile && git commit -m "using version ${tag}" && git push 24 | git tag "${tag}" && git push --tags 25 | fi 26 | done 27 | } 28 | 29 | delete_ignored_tags 30 | build_missing_tags 31 | -------------------------------------------------------------------------------- /entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | USER_NAME=${USER:-root} 4 | USER_ID=${LOCAL_USER_ID:-0} 5 | GROUP_ID=${LOCAL_GROUP_ID:-0} 6 | 7 | if [ "${USER_ID}" -ne "0" ]; then 8 | groupadd -g ${GROUP_ID} ${USER_NAME} &> /dev/null 9 | useradd --shell /bin/bash -M -u ${USER_ID} -g ${GROUP_ID} -o -c "" ${USER_NAME} 10 | usermod -aG sudo ${USER_NAME} 11 | 12 | /usr/local/bin/gosu ${USER_NAME} /bin/bash -c "$@" 13 | else 14 | exec "$@" 15 | fi 16 | -------------------------------------------------------------------------------- /gather_tags: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | curl -fqs http://downloads.dlang.org/releases/2.x/ | grep 'li.*href.*release' | cut -d '>' -f 3 | cut -d '<' -f 1 | sort 3 | --------------------------------------------------------------------------------