├── .gitignore ├── .travis.yml ├── Makefile ├── README.md ├── alpine ├── .gitignore ├── Makefile └── dlang.docker ├── amazonlinux ├── .gitignore ├── Makefile └── dlang.docker ├── circleci ├── .gitignore ├── Dockerfile-basic.template ├── Makefile ├── dlang.docker └── template.docker ├── common.mak ├── example-app ├── .gitignore ├── Dockerfile ├── Makefile ├── dub.sdl └── source │ └── app.d └── ubuntu ├── .gitignore ├── Makefile └── dlang.docker /.gitignore: -------------------------------------------------------------------------------- 1 | example-app/app 2 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: d 2 | services: 3 | - docker 4 | 5 | branches: 6 | only: 7 | - master 8 | 9 | env: 10 | - D_VERSION=dmd-beta 11 | - D_VERSION=dmd 12 | - D_VERSION=ldc-beta 13 | - D_VERSION=ldc 14 | - D_VERSION=gdc 15 | 16 | matrix: 17 | allow_failures: 18 | - env: D_VERSION=gdc 19 | 20 | script: 21 | - export D_VERSION_RESOLVED=$(~/dlang/install.sh ${D_VERSION} | sed -n -e "s/.*source ~\/dlang\/\(.*\)\/activate.*/\1/p") 22 | - env 23 | - make build D_VERSION=${D_VERSION} D_VERSION_RESOLVED=${D_VERSION_RESOLVED} 24 | - if [ "$D_VERSION" == "dmd" ] ; then make test ; fi 25 | 26 | after_success: 27 | - if [ "$TRAVIS_BRANCH" == "master" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ] ; then docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD" ; fi 28 | - if [ "$TRAVIS_BRANCH" == "master" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then make push D_VERSION=${D_VERSION} D_VERSION_RESOLVED=${D_VERSION_RESOLVED}; fi 29 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | export D_VERSION_RESOLVED=dmd-2.077.1 2 | export DOCKER_ORG=dlang2 3 | export D_VERSION=dmd 4 | 5 | build: 6 | $(MAKE) -C circleci build 7 | $(MAKE) -C ubuntu build 8 | #$(MAKE) -C alpine build 9 | $(MAKE) -C amazonlinux build 10 | $(MAKE) -C amazonlinux clean 11 | $(MAKE) -C amazonlinux build DOCKER_POSTFIX=-amazonlinux2 BASE_IMAGE=amazonlinux:2 12 | 13 | push: 14 | $(MAKE) -C circleci push 15 | $(MAKE) -C ubuntu push 16 | #$(MAKE) -C alpine push 17 | $(MAKE) -C amazonlinux push 18 | $(MAKE) -C amazonlinux push DOCKER_POSTFIX=-amazonlinux2 19 | 20 | test: 21 | $(MAKE) -C example-app test 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | D docker images 2 | =============== 3 | 4 | [![Build Status](https://travis-ci.org/wilzbach/dlang-docker.svg?branch=master)](https://travis-ci.org/wilzbach/dlang-docker) 5 | 6 | ```yaml 7 | version: 2 8 | jobs: 9 | build: 10 | docker: 11 | - image: dlang2/dmd-circleci 12 | ``` 13 | 14 | Ubuntu 15 | ------ 16 | 17 | The default tag (`latest`) is the last stable release. 18 | 19 | ### Example 20 | 21 | ```dockerfile 22 | FROM: dlang2/dmd-ubuntu:2.077.1 23 | WORKDIR /dlang/app 24 | COPY . . 25 | 26 | RUN dub build -v 27 | CMD ["/dlang/app/app"] 28 | ``` 29 | 30 | See the [`example-app`](https://github.com/wilzbach/dlang-docker/tree/master/example-app). 31 | 32 | ### Available tags 33 | 34 | - https://hub.docker.com/r/dlang2/dmd-ubuntu/tags/ 35 | - https://hub.docker.com/r/dlang2/ldc-ubuntu/tags/ 36 | - https://hub.docker.com/r/dlang2/gdc-ubuntu/tags/ 37 | 38 | This repo is fully automated and new releases get deployed automatically. 39 | 40 | CircleCi: Available tags 41 | -------------- 42 | 43 | The default tag (`latest`) is the last stable release. 44 | 45 | ### DMD 46 | 47 | ```yaml 48 | - image: dlang2/dmd-circleci:nightly 49 | - image: dlang2/dmd-circleci:beta 50 | - image: dlang2/dmd-circleci 51 | - image: dlang2/dmd-circleci:2.077.1 52 | ``` 53 | 54 | ### LDC 55 | 56 | ```yaml 57 | - image: dlang2/ldc-circleci:beta 58 | - image: dlang2/ldc-circleci 59 | - image: dlang2/ldc-circleci:1.6.0 60 | ``` 61 | 62 | ### GDC 63 | 64 | ```yaml 65 | - image: dlang2/gdc-circleci 66 | - image: dlang2/gdc-circleci:4.8.5 67 | ``` 68 | 69 | Full list: 70 | 71 | - https://hub.docker.com/r/dlang2/dmd-circleci/tags/ 72 | - https://hub.docker.com/r/dlang2/ldc-circleci/tags/ 73 | - https://hub.docker.com/r/dlang2/gdc-circleci/tags/ 74 | -------------------------------------------------------------------------------- /alpine/.gitignore: -------------------------------------------------------------------------------- 1 | Dockerfile 2 | -------------------------------------------------------------------------------- /alpine/Makefile: -------------------------------------------------------------------------------- 1 | BASE_IMAGE="alpine:3.7" 2 | DOCKER_POSTFIX=-alpine 3 | 4 | include ../common.mak 5 | 6 | Dockerfile: dlang.docker Makefile 7 | cat $< | \ 8 | sed "s|{{D_VERSION}}|${D_VERSION_RESOLVED}|g" | \ 9 | sed "s|{{BASE_IMAGE}}|${BASE_IMAGE}|g" | \ 10 | sed "s|{{BIN_FOLDER}}|${BIN_FOLDER}|g" | \ 11 | sed "s|{{LIB_FOLDER}}|${LIB_FOLDER}|g" \ 12 | > $@ 13 | -------------------------------------------------------------------------------- /alpine/dlang.docker: -------------------------------------------------------------------------------- 1 | FROM {{BASE_IMAGE}} 2 | 3 | ENV D_VERSION {{D_VERSION}} 4 | ENV BIN_FOLDER {{BIN_FOLDER}} 5 | ENV LIB_FOLDER {{LIB_FOLDER}} 6 | ENV DEBIAN_FRONTEND=noninteractive 7 | ENV DPATH=/dlang 8 | 9 | RUN set -eux; \ 10 | apk add --no-cache \ 11 | bash \ 12 | binutils-gold \ 13 | ca-certificates \ 14 | curl \ 15 | gcc \ 16 | g++ \ 17 | libstdc++ \ 18 | gnupg \ 19 | libevent-dev \ 20 | make \ 21 | openssl-dev \ 22 | xz 23 | 24 | RUN wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://raw.githubusercontent.com/sgerrand/alpine-pkg-glibc/master/sgerrand.rsa.pub && \ 25 | wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.26-r0/glibc-2.26-r0.apk && \ 26 | apk add glibc-2.26-r0.apk && \ 27 | rm glibc-2.26-r0.apk /etc/apk/keys/sgerrand.rsa.pub 28 | 29 | RUN ln -s /usr/bin/ld.gold /usr/local/bin/ld 30 | 31 | RUN set -ex && \ 32 | curl -fsS https://dlang.org/install.sh | bash -s ${D_VERSION} -p ${DPATH} 33 | 34 | ENV PATH="${DPATH}/${D_VERSION}/${BIN_FOLDER}:${PATH}" 35 | ENV LIBRARY_PATH="${DPATH}/${D_VERSION}/${LIB_FOLDER}:${LIBRARY_PATH}" 36 | ENV LD_LIBRARY_PATH="${DPATH}/${D_VERSION}/${LIB_FOLDER}:${LD_LIBRARY_PATH}" 37 | RUN chmod 755 -R ${DPATH} 38 | RUN echo "${DPATH}/${D_VERSION}/activate" >> /etc/profile 39 | -------------------------------------------------------------------------------- /amazonlinux/.gitignore: -------------------------------------------------------------------------------- 1 | Dockerfile 2 | -------------------------------------------------------------------------------- /amazonlinux/Makefile: -------------------------------------------------------------------------------- 1 | BASE_IMAGE="amazonlinux:1" 2 | DOCKER_POSTFIX=-amazonlinux 3 | 4 | include ../common.mak 5 | 6 | Dockerfile: dlang.docker Makefile 7 | cat $< | \ 8 | sed "s|{{D_VERSION}}|${D_VERSION_RESOLVED}|g" | \ 9 | sed "s|{{BASE_IMAGE}}|${BASE_IMAGE}|g" | \ 10 | sed "s|{{BIN_FOLDER}}|${BIN_FOLDER}|g" | \ 11 | sed "s|{{LIB_FOLDER}}|${LIB_FOLDER}|g" \ 12 | > $@ 13 | 14 | clean: 15 | rm Dockerfile 16 | -------------------------------------------------------------------------------- /amazonlinux/dlang.docker: -------------------------------------------------------------------------------- 1 | FROM {{BASE_IMAGE}} 2 | 3 | ENV D_VERSION {{D_VERSION}} 4 | ENV BIN_FOLDER {{BIN_FOLDER}} 5 | ENV LIB_FOLDER {{LIB_FOLDER}} 6 | ENV DPATH=/dlang 7 | 8 | RUN set -ex && \ 9 | yum update -y && \ 10 | yum install -y gcc tar xz libevent-devel shadow-utils 11 | 12 | RUN groupadd --gid 1000 dlang \ 13 | && useradd --uid 1000 --gid dlang --shell /bin/bash --create-home dlang 14 | 15 | RUN mkdir ${DPATH}\ 16 | && chown dlang ${DPATH} 17 | 18 | USER dlang 19 | 20 | RUN set -ex && \ 21 | curl -fsS https://dlang.org/install.sh | bash -s ${D_VERSION} -p ${DPATH} && \ 22 | chmod 755 -R ${DPATH} 23 | 24 | USER root 25 | 26 | RUN ln -s ${DPATH}/${D_VERSION} ${DPATH}/dc && ls ${DPATH} 27 | 28 | ENV PATH="${DPATH}/${D_VERSION}/${BIN_FOLDER}:${PATH}" 29 | ENV LIBRARY_PATH="${DPATH}/${D_VERSION}/${LIB_FOLDER}:${LIBRARY_PATH}" 30 | ENV LD_LIBRARY_PATH="${DPATH}/${D_VERSION}/${LIB_FOLDER}:${LD_LIBRARY_PATH}" 31 | -------------------------------------------------------------------------------- /circleci/.gitignore: -------------------------------------------------------------------------------- 1 | Dockerfile 2 | -------------------------------------------------------------------------------- /circleci/Dockerfile-basic.template: -------------------------------------------------------------------------------- 1 | FROM {{BASE_IMAGE}} 2 | 3 | # make Apt non-interactive 4 | RUN echo 'APT::Get::Assume-Yes "true";' > /etc/apt/apt.conf.d/90circleci \ 5 | && echo 'DPkg::Options "--force-confnew";' >> /etc/apt/apt.conf.d/90circleci 6 | 7 | ENV DEBIAN_FRONTEND=noninteractive 8 | 9 | # man directory is missing in some base images 10 | # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=863199 11 | RUN apt-get update \ 12 | && mkdir -p /usr/share/man/man1 \ 13 | && apt-get install -y \ 14 | git mercurial xvfb \ 15 | locales sudo openssh-client ca-certificates tar gzip parallel \ 16 | net-tools netcat unzip zip bzip2 gnupg curl wget 17 | 18 | 19 | # Set timezone to UTC by default 20 | RUN ln -sf /usr/share/zoneinfo/Etc/UTC /etc/localtime 21 | 22 | # Use unicode 23 | RUN locale-gen C.UTF-8 || true 24 | ENV LANG=C.UTF-8 25 | 26 | # install jq 27 | RUN JQ_URL="https://circle-downloads.s3.amazonaws.com/circleci-images/cache/linux-amd64/jq-latest" \ 28 | && curl --silent --show-error --location --fail --retry 3 --output /usr/bin/jq $JQ_URL \ 29 | && chmod +x /usr/bin/jq \ 30 | && jq --version 31 | 32 | # Install Docker 33 | 34 | # Docker.com returns the URL of the latest binary when you hit a directory listing 35 | # We curl this URL and `grep` the version out. 36 | # The output looks like this: 37 | 38 | #> # To install, run the following commands as root: 39 | #> curl -fsSLO https://download.docker.com/linux/static/stable/x86_64/docker-17.05.0-ce.tgz && tar --strip-components=1 -xvzf docker-17.05.0-ce.tgz -C /usr/local/bin 40 | #> 41 | #> # Then start docker in daemon mode: 42 | #> /usr/local/bin/dockerd 43 | 44 | RUN set -ex \ 45 | && export DOCKER_VERSION=$(curl --silent --fail --retry 3 https://download.docker.com/linux/static/stable/x86_64/ | grep -o -e 'docker-[.0-9]*-ce\.tgz' | sort -r | head -n 1) \ 46 | && DOCKER_URL="https://download.docker.com/linux/static/stable/x86_64/${DOCKER_VERSION}" \ 47 | && echo Docker URL: $DOCKER_URL \ 48 | && curl --silent --show-error --location --fail --retry 3 --output /tmp/docker.tgz "${DOCKER_URL}" \ 49 | && ls -lha /tmp/docker.tgz \ 50 | && tar -xz -C /tmp -f /tmp/docker.tgz \ 51 | && mv /tmp/docker/* /usr/bin \ 52 | && rm -rf /tmp/docker /tmp/docker.tgz \ 53 | && which docker \ 54 | && (docker version || true) 55 | 56 | # docker compose 57 | RUN COMPOSE_URL="https://circle-downloads.s3.amazonaws.com/circleci-images/cache/linux-amd64/docker-compose-latest" \ 58 | && curl --silent --show-error --location --fail --retry 3 --output /usr/bin/docker-compose $COMPOSE_URL \ 59 | && chmod +x /usr/bin/docker-compose \ 60 | && docker-compose version 61 | 62 | # install dockerize 63 | RUN DOCKERIZE_URL="https://circle-downloads.s3.amazonaws.com/circleci-images/cache/linux-amd64/dockerize-latest.tar.gz" \ 64 | && curl --silent --show-error --location --fail --retry 3 --output /tmp/dockerize-linux-amd64.tar.gz $DOCKERIZE_URL \ 65 | && tar -C /usr/local/bin -xzvf /tmp/dockerize-linux-amd64.tar.gz \ 66 | && rm -rf /tmp/dockerize-linux-amd64.tar.gz \ 67 | && dockerize --version 68 | 69 | RUN groupadd --gid 3434 circleci \ 70 | && useradd --uid 3434 --gid circleci --shell /bin/bash --create-home circleci \ 71 | && echo 'circleci ALL=NOPASSWD: ALL' >> /etc/sudoers.d/50-circleci \ 72 | && echo 'Defaults env_keep += "DEBIAN_FRONTEND"' >> /etc/sudoers.d/env_keep 73 | 74 | # BEGIN IMAGE CUSTOMIZATIONS 75 | # END IMAGE CUSTOMIZATIONS 76 | 77 | USER circleci 78 | 79 | CMD ["/bin/sh"] 80 | -------------------------------------------------------------------------------- /circleci/Makefile: -------------------------------------------------------------------------------- 1 | # A sane variant to the CircleCi scripts 2 | 3 | BASE_IMAGE="ubuntu:18.04" 4 | DOCKER_POSTFIX=-circleci 5 | 6 | include ../common.mak 7 | 8 | template.docker: 9 | curl https://raw.githubusercontent.com/circleci/circleci-images/6bc21feff1f7af80654a12f9c6db6cdcfc725d49/shared/images/Dockerfile-basic.template > $@ 10 | 11 | Dockerfile: dlang.docker template.docker Makefile 12 | cat dlang.docker | \ 13 | sed "s|{{D_VERSION}}|${D_VERSION_RESOLVED}|g" |\ 14 | sed "s|{{BIN_FOLDER}}|${BIN_FOLDER}|g" | \ 15 | sed "s|{{LIB_FOLDER}}|${LIB_FOLDER}|g" \ 16 | > dlang.docker.tmp 17 | cat template.docker | \ 18 | sed "s|{{BASE_IMAGE}}|${BASE_IMAGE}|g" | \ 19 | sed "/# BEGIN IMAGE CUSTOMIZATIONS/ r dlang.docker.tmp" > $@ 20 | rm dlang.docker.tmp 21 | -------------------------------------------------------------------------------- /circleci/dlang.docker: -------------------------------------------------------------------------------- 1 | ENV D_VERSION {{D_VERSION}} 2 | ENV BIN_FOLDER {{BIN_FOLDER}} 3 | ENV LIB_FOLDER {{LIB_FOLDER}} 4 | ENV DPATH=/dlang 5 | 6 | RUN set -ex && \ 7 | apt-get update && \ 8 | apt-get install --no-install-recommends -y \ 9 | ca-certificates \ 10 | curl \ 11 | libc6-dev \ 12 | g++-multilib \ 13 | gdb \ 14 | libevent-dev \ 15 | libssl-dev \ 16 | libz-dev \ 17 | make \ 18 | xz-utils \ 19 | && update-alternatives --install "/usr/bin/ld" "ld" "/usr/bin/ld.gold" 20 \ 20 | && update-alternatives --install "/usr/bin/ld" "ld" "/usr/bin/ld.bfd" 10 21 | 22 | RUN set -ex && \ 23 | curl -fsS https://dlang.org/install.sh | bash -s ${D_VERSION} -p /dlang 24 | 25 | RUN ln -s ${DPATH}/${D_VERSION} ${DPATH}/dc && ls ${DPATH} 26 | 27 | ENV PATH="${DPATH}/${D_VERSION}/${BIN_FOLDER}:${PATH}" 28 | ENV LIBRARY_PATH="${DPATH}/${D_VERSION}/${LIB_FOLDER}:${LIBRARY_PATH}" 29 | ENV LD_LIBRARY_PATH="${DPATH}/${D_VERSION}/${LIB_FOLDER}:${LD_LIBRARY_PATH}" 30 | RUN set -ex && \ 31 | chmod 555 -R /dlang && \ 32 | chown circleci:circleci -R /dlang 33 | -------------------------------------------------------------------------------- /circleci/template.docker: -------------------------------------------------------------------------------- 1 | FROM {{BASE_IMAGE}} 2 | 3 | # make Apt non-interactive 4 | RUN echo 'APT::Get::Assume-Yes "true";' > /etc/apt/apt.conf.d/90circleci \ 5 | && echo 'DPkg::Options "--force-confnew";' >> /etc/apt/apt.conf.d/90circleci 6 | 7 | ENV DEBIAN_FRONTEND=noninteractive 8 | 9 | # man directory is missing in some base images 10 | # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=863199 11 | RUN apt-get update \ 12 | && mkdir -p /usr/share/man/man1 \ 13 | && apt-get install -y \ 14 | git mercurial xvfb \ 15 | locales sudo openssh-client ca-certificates tar gzip parallel \ 16 | net-tools netcat unzip zip bzip2 gnupg curl wget 17 | 18 | 19 | # Set timezone to UTC by default 20 | RUN ln -sf /usr/share/zoneinfo/Etc/UTC /etc/localtime 21 | 22 | # Use unicode 23 | RUN locale-gen C.UTF-8 || true 24 | ENV LANG=C.UTF-8 25 | 26 | # install jq 27 | RUN JQ_URL="https://circle-downloads.s3.amazonaws.com/circleci-images/cache/linux-amd64/jq-latest" \ 28 | && curl --silent --show-error --location --fail --retry 3 --output /usr/bin/jq $JQ_URL \ 29 | && chmod +x /usr/bin/jq \ 30 | && jq --version 31 | 32 | # Install Docker 33 | 34 | # Docker.com returns the URL of the latest binary when you hit a directory listing 35 | # We curl this URL and `grep` the version out. 36 | # The output looks like this: 37 | 38 | #> # To install, run the following commands as root: 39 | #> curl -fsSLO https://download.docker.com/linux/static/stable/x86_64/docker-17.05.0-ce.tgz && tar --strip-components=1 -xvzf docker-17.05.0-ce.tgz -C /usr/local/bin 40 | #> 41 | #> # Then start docker in daemon mode: 42 | #> /usr/local/bin/dockerd 43 | 44 | RUN set -ex \ 45 | && export DOCKER_VERSION=$(curl --silent --fail --retry 3 https://download.docker.com/linux/static/stable/x86_64/ | grep -o -e 'docker-[.0-9]*-ce\.tgz' | sort -r | head -n 1) \ 46 | && DOCKER_URL="https://download.docker.com/linux/static/stable/x86_64/${DOCKER_VERSION}" \ 47 | && echo Docker URL: $DOCKER_URL \ 48 | && curl --silent --show-error --location --fail --retry 3 --output /tmp/docker.tgz "${DOCKER_URL}" \ 49 | && ls -lha /tmp/docker.tgz \ 50 | && tar -xz -C /tmp -f /tmp/docker.tgz \ 51 | && mv /tmp/docker/* /usr/bin \ 52 | && rm -rf /tmp/docker /tmp/docker.tgz \ 53 | && which docker \ 54 | && (docker version || true) 55 | 56 | # docker compose 57 | RUN COMPOSE_URL="https://circle-downloads.s3.amazonaws.com/circleci-images/cache/linux-amd64/docker-compose-latest" \ 58 | && curl --silent --show-error --location --fail --retry 3 --output /usr/bin/docker-compose $COMPOSE_URL \ 59 | && chmod +x /usr/bin/docker-compose \ 60 | && docker-compose version 61 | 62 | # install dockerize 63 | RUN DOCKERIZE_URL="https://circle-downloads.s3.amazonaws.com/circleci-images/cache/linux-amd64/dockerize-latest.tar.gz" \ 64 | && curl --silent --show-error --location --fail --retry 3 --output /tmp/dockerize-linux-amd64.tar.gz $DOCKERIZE_URL \ 65 | && tar -C /usr/local/bin -xzvf /tmp/dockerize-linux-amd64.tar.gz \ 66 | && rm -rf /tmp/dockerize-linux-amd64.tar.gz \ 67 | && dockerize --version 68 | 69 | RUN groupadd --gid 3434 circleci \ 70 | && useradd --uid 3434 --gid circleci --shell /bin/bash --create-home circleci \ 71 | && echo 'circleci ALL=NOPASSWD: ALL' >> /etc/sudoers.d/50-circleci \ 72 | && echo 'Defaults env_keep += "DEBIAN_FRONTEND"' >> /etc/sudoers.d/env_keep 73 | 74 | # BEGIN IMAGE CUSTOMIZATIONS 75 | # END IMAGE CUSTOMIZATIONS 76 | 77 | USER circleci 78 | 79 | CMD ["/bin/sh"] 80 | -------------------------------------------------------------------------------- /common.mak: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Global variables 3 | ################################################################################ 4 | 5 | DOCKER_ORG=dlang2 6 | D_VERSION=dmd 7 | 8 | ################################################################################ 9 | # Automatically set variables 10 | ################################################################################ 11 | # The canonical name of the resolved tag 12 | D_VERSION_RESOLVED=dmd-2.077.1 13 | D_COMPILER=$(firstword $(subst -, ,$(D_VERSION))) 14 | DOCKER_IMAGE_BASE=$(D_COMPILER)$(DOCKER_POSTFIX) 15 | # The alias for the img, e.g. dmd-nightly 16 | # Don't specify a tag for the latest stable bins (e.g. dmd) 17 | ifneq (,$(findstring $(D_COMPILER)-,$(D_VERSION))) 18 | DOCKER_IMAGE_NAME=$(DOCKER_IMAGE_BASE):$(subst $(D_COMPILER)-,,$(D_VERSION)) 19 | else 20 | DOCKER_IMAGE_NAME=$(DOCKER_IMAGE_BASE):latest 21 | endif 22 | # The canonical name, e.g. dmd:2.077.1 23 | DOCKER_IMAGE_NAME_RESOLVED=$(DOCKER_IMAGE_BASE):$(subst $(D_COMPILER)-,,$(D_VERSION_RESOLVED)) 24 | # LDC is installed as ldc2 25 | D_COMPILER_EXEC=$(subst ldc,ldc2,$(D_COMPILER)) 26 | BIN_FOLDER=$(subst gdc,bin,$(subst ldc,bin,$(subst dmd,linux/bin64,$(D_COMPILER)))) 27 | LIB_FOLDER=$(subst gdc,lib64,$(subst ldc,lib,$(subst dmd,linux/lib64,$(D_COMPILER)))) 28 | 29 | build: Dockerfile 30 | docker build -t $(DOCKER_ORG)/$(DOCKER_IMAGE_NAME) . 31 | docker build -t $(DOCKER_ORG)/$(DOCKER_IMAGE_NAME_RESOLVED) . 32 | docker run --rm -i -t $(DOCKER_ORG)/$(DOCKER_IMAGE_NAME_RESOLVED) ${D_COMPILER_EXEC} --version | grep -i "${D_COMPILER}" 33 | 34 | push: build 35 | docker push $(DOCKER_ORG)/$(DOCKER_IMAGE_NAME) 36 | docker push $(DOCKER_ORG)/$(DOCKER_IMAGE_NAME_RESOLVED) 37 | -------------------------------------------------------------------------------- /example-app/.gitignore: -------------------------------------------------------------------------------- 1 | .dub 2 | docs.json 3 | __dummy.html 4 | docs/ 5 | app.so 6 | app.dylib 7 | app.dll 8 | app.a 9 | app.lib 10 | app-test-* 11 | *.exe 12 | *.o 13 | *.obj 14 | *.lst 15 | -------------------------------------------------------------------------------- /example-app/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM dlang2/dmd-ubuntu 2 | WORKDIR /dlang/app 3 | COPY . . 4 | 5 | RUN dub build -v 6 | CMD ["/dlang/app/app"] 7 | -------------------------------------------------------------------------------- /example-app/Makefile: -------------------------------------------------------------------------------- 1 | 2 | test: 3 | docker build -t myorg/myapp . 4 | docker run -t myorg/myapp | grep "Hello D" 5 | -------------------------------------------------------------------------------- /example-app/dub.sdl: -------------------------------------------------------------------------------- 1 | name "app" 2 | description "A minimal D application." 3 | authors "seb" 4 | copyright "Copyright © 2018, seb" 5 | license "BSL-1.0" 6 | -------------------------------------------------------------------------------- /example-app/source/app.d: -------------------------------------------------------------------------------- 1 | import std.stdio; 2 | 3 | void main() 4 | { 5 | writeln("Hello D."); 6 | } 7 | -------------------------------------------------------------------------------- /ubuntu/.gitignore: -------------------------------------------------------------------------------- 1 | Dockerfile 2 | -------------------------------------------------------------------------------- /ubuntu/Makefile: -------------------------------------------------------------------------------- 1 | BASE_IMAGE="ubuntu:18.04" 2 | DOCKER_POSTFIX=-ubuntu 3 | 4 | include ../common.mak 5 | 6 | Dockerfile: dlang.docker Makefile 7 | cat $< | \ 8 | sed "s|{{D_VERSION}}|${D_VERSION_RESOLVED}|g" | \ 9 | sed "s|{{BASE_IMAGE}}|${BASE_IMAGE}|g" | \ 10 | sed "s|{{BIN_FOLDER}}|${BIN_FOLDER}|g" | \ 11 | sed "s|{{LIB_FOLDER}}|${LIB_FOLDER}|g" \ 12 | > $@ 13 | -------------------------------------------------------------------------------- /ubuntu/dlang.docker: -------------------------------------------------------------------------------- 1 | FROM {{BASE_IMAGE}} 2 | 3 | ENV D_VERSION {{D_VERSION}} 4 | ENV BIN_FOLDER {{BIN_FOLDER}} 5 | ENV LIB_FOLDER {{LIB_FOLDER}} 6 | ENV DEBIAN_FRONTEND=noninteractive 7 | ENV DPATH=/dlang 8 | 9 | RUN set -ex && \ 10 | apt-get update && \ 11 | apt-get install --no-install-recommends -y \ 12 | ca-certificates \ 13 | curl \ 14 | libc6-dev \ 15 | gcc \ 16 | libevent-dev \ 17 | libssl-dev \ 18 | libxml2 \ 19 | libz-dev \ 20 | gpg \ 21 | make \ 22 | xz-utils \ 23 | && update-alternatives --install "/usr/bin/ld" "ld" "/usr/bin/ld.gold" 20 \ 24 | && update-alternatives --install "/usr/bin/ld" "ld" "/usr/bin/ld.bfd" 10 25 | 26 | RUN groupadd --gid 1000 dlang \ 27 | && useradd --uid 1000 --gid dlang --shell /bin/bash --create-home dlang 28 | 29 | RUN mkdir ${DPATH}\ 30 | && chown dlang ${DPATH} 31 | 32 | USER dlang 33 | 34 | RUN set -ex && \ 35 | curl -fsS https://dlang.org/install.sh | bash -s ${D_VERSION} -p ${DPATH} 36 | 37 | USER root 38 | 39 | RUN chmod 755 -R ${DPATH} 40 | RUN ln -s ${DPATH}/${D_VERSION} ${DPATH}/dc && ls ${DPATH} 41 | 42 | ENV PATH="${DPATH}/${D_VERSION}/${BIN_FOLDER}:${PATH}" 43 | ENV LIBRARY_PATH="${DPATH}/${D_VERSION}/${LIB_FOLDER}:${LIBRARY_PATH}" 44 | ENV LD_LIBRARY_PATH="${DPATH}/${D_VERSION}/${LIB_FOLDER}:${LD_LIBRARY_PATH}" 45 | --------------------------------------------------------------------------------