Skip to content

Commit 63b3c38

Browse files
committed
Build docker executable with musl libc.
1 parent e3ff391 commit 63b3c38

File tree

5 files changed

+58
-3
lines changed

5 files changed

+58
-3
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM busybox:glibc
1+
FROM busybox
22

33
MAINTAINER "André Stein <[email protected]>"
44

ci/Dockerfile

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
FROM alpine:3.10
2+
3+
ENV DUB_BRANCH "v1.20.1"
4+
ENV RDMD_BRANCH "v2.091.0"
5+
6+
RUN apk add --no-cache llvm5-libs g++ binutils-gold clang \
7+
llvm8-libs llvm8-static llvm8-dev \
8+
cmake ninja zlib-dev curl-dev curl-static openssl-dev git make
9+
10+
# build ldc2 ########################################################
11+
12+
ADD https://github.com/ldc-developers/ldc/releases/download/v1.13.0/ldc2-1.13.0-alpine-linux-x86_64.tar.xz /ldc-bin.tar.xz
13+
RUN tar xf ldc-bin.tar.xz
14+
15+
# TODO: use environment variable from travis for LDC version
16+
ADD https://github.com/ldc-developers/ldc/releases/download/v1.21.0/ldc-1.21.0-src.tar.gz /ldc-src.tar.xz
17+
RUN tar xf ldc-src.tar.xz
18+
19+
RUN mkdir /ldc-1.21.0-src/build \
20+
&& cd /ldc-1.21.0-src/build \
21+
&& cmake -G Ninja .. -DCMAKE_BUILD_TYPE=Release \
22+
-DD_COMPILER=/ldc2-1.13.0-alpine-linux-x86_64/bin/ldmd2 \
23+
&& ninja -j2 \
24+
&& ninja install
25+
26+
# build dub ##########################################################
27+
28+
RUN git clone --single-branch --branch ${DUB_BRANCH} https://github.com/dlang/dub \
29+
&& cd dub \
30+
&& ldmd2 -run build.d \
31+
&& cp bin/dub /usr/local/bin/
32+
33+
# build rdmd #########################################################
34+
35+
RUN git clone --single-branch --branch ${RDMD_BRANCH} https://github.com/dlang/tools \
36+
&& cd tools \
37+
&& sed -i "s|^DMD = .*$|DMD = ldmd2|" posix.mak \
38+
&& sed -i "s|^INSTALL_DIR = .*$|INSTALL_DIR = $PWD|" posix.mak \
39+
&& make -f posix.mak install \
40+
&& cp bin/rdmd /usr/local/bin/
41+
42+
43+
COPY docker.build.sh /docker.build.sh
44+
RUN chmod +x /docker.build.sh
45+
46+
ENTRYPOINT [ "/docker.build.sh" ]

ci/docker.build.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/sh
2+
set -e -u
3+
4+
cd /core/
5+
dub build -c static --compiler=ldc2

ci/travis.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ dub --compiler=${DC} -- --sanitycheck
1919

2020
# Compile to static binary with ldc
2121
if [[ "${DC}" == "ldc2" ]]; then
22-
dub build -c static --compiler=${DC}
22+
docker build -t dlangtour_build ./ci/
23+
docker run --rm -v `pwd`:/core/ -ti dlangtour_build
24+
2325
docker build -t dlangtour_test_image ./
2426
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -ti dlangtour_test_image --wait-until-pulled --sanitycheck
2527
fi

dub.sdl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ configuration "static" {
2222
targetType "executable"
2323
versions "VibeDefaultMain"
2424
lflags "-lz" "-lssl" "-lcrypto" "-ldl" platform="posix"
25-
dflags "-static" platform="posix"
25+
26+
// gcc on alpine has issues with the ld.gold linker, use bfd instead
27+
dflags "-linker=bfd" "-static" platform="posix"
2628
}
2729
configuration "library" {
2830
versions "VibeCustomMain"

0 commit comments

Comments
 (0)