From 1c26588c1313905349cfb2ebc4d238a4ba0d7dcd Mon Sep 17 00:00:00 2001 From: looked-at-me Date: Fri, 8 May 2020 02:09:15 +0000 Subject: [PATCH 1/7] Build docker executable with musl libc. --- Dockerfile | 2 +- ci/Dockerfile | 46 ++++++++++++++++++++++++++++++++++++++++++++++ ci/docker.build.sh | 5 +++++ ci/travis.sh | 4 +++- dub.sdl | 4 +++- 5 files changed, 58 insertions(+), 3 deletions(-) create mode 100644 ci/Dockerfile create mode 100644 ci/docker.build.sh diff --git a/Dockerfile b/Dockerfile index 98980cb8..362e7a92 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM busybox:glibc +FROM busybox MAINTAINER "André Stein " diff --git a/ci/Dockerfile b/ci/Dockerfile new file mode 100644 index 00000000..6aec8620 --- /dev/null +++ b/ci/Dockerfile @@ -0,0 +1,46 @@ +FROM alpine:3.10 + +ENV DUB_BRANCH "v1.20.1" +ENV RDMD_BRANCH "v2.091.0" + +RUN apk add --no-cache llvm5-libs g++ binutils-gold clang \ + llvm8-libs llvm8-static llvm8-dev \ + cmake ninja zlib-dev curl-dev curl-static openssl-dev git make + +# build ldc2 ######################################################## + +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 +RUN tar xf ldc-bin.tar.xz + +# TODO: use environment variable from travis for LDC version +ADD https://github.com/ldc-developers/ldc/releases/download/v1.21.0/ldc-1.21.0-src.tar.gz /ldc-src.tar.xz +RUN tar xf ldc-src.tar.xz + +RUN mkdir /ldc-1.21.0-src/build \ + && cd /ldc-1.21.0-src/build \ + && cmake -G Ninja .. -DCMAKE_BUILD_TYPE=Release \ + -DD_COMPILER=/ldc2-1.13.0-alpine-linux-x86_64/bin/ldmd2 \ + && ninja -j2 \ + && ninja install + +# build dub ########################################################## + +RUN git clone --single-branch --branch ${DUB_BRANCH} https://github.com/dlang/dub \ + && cd dub \ + && ldmd2 -run build.d \ + && cp bin/dub /usr/local/bin/ + +# build rdmd ######################################################### + +RUN git clone --single-branch --branch ${RDMD_BRANCH} https://github.com/dlang/tools \ + && cd tools \ + && sed -i "s|^DMD = .*$|DMD = ldmd2|" posix.mak \ + && sed -i "s|^INSTALL_DIR = .*$|INSTALL_DIR = $PWD|" posix.mak \ + && make -f posix.mak install \ + && cp bin/rdmd /usr/local/bin/ + + +COPY docker.build.sh /docker.build.sh +RUN chmod +x /docker.build.sh + +ENTRYPOINT [ "/docker.build.sh" ] diff --git a/ci/docker.build.sh b/ci/docker.build.sh new file mode 100644 index 00000000..5f30225f --- /dev/null +++ b/ci/docker.build.sh @@ -0,0 +1,5 @@ +#!/bin/sh +set -e -u + +cd /core/ +dub build -c static --compiler=ldc2 diff --git a/ci/travis.sh b/ci/travis.sh index 0de864ce..c6998861 100755 --- a/ci/travis.sh +++ b/ci/travis.sh @@ -19,7 +19,9 @@ dub --compiler=${DC} -- --sanitycheck # Compile to static binary with ldc if [[ "${DC}" == "ldc2" ]]; then - dub build -c static --compiler=${DC} + docker build -t dlangtour_build ./ci/ + docker run --rm -v `pwd`:/core/ -ti dlangtour_build + docker build -t dlangtour_test_image ./ docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -ti dlangtour_test_image --wait-until-pulled --sanitycheck fi diff --git a/dub.sdl b/dub.sdl index f49daa11..6c5f18e0 100644 --- a/dub.sdl +++ b/dub.sdl @@ -22,7 +22,9 @@ configuration "static" { targetType "executable" versions "VibeDefaultMain" lflags "-lz" "-lssl" "-lcrypto" "-ldl" platform="posix" - dflags "-static" platform="posix" + + // gcc on alpine has issues with the ld.gold linker, use bfd instead + dflags "-linker=bfd" "-static" platform="posix" } configuration "library" { versions "VibeCustomMain" From 30576a95f31cd0727dbe50f2d02e70c435e887c1 Mon Sep 17 00:00:00 2001 From: looked-at-me Date: Fri, 8 May 2020 03:35:35 +0000 Subject: [PATCH 2/7] Change linker with DFLAGS instead --- ci/Dockerfile | 2 +- ci/docker.build.sh | 2 +- dub.sdl | 4 +--- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/ci/Dockerfile b/ci/Dockerfile index 6aec8620..ead50419 100644 --- a/ci/Dockerfile +++ b/ci/Dockerfile @@ -5,7 +5,7 @@ ENV RDMD_BRANCH "v2.091.0" RUN apk add --no-cache llvm5-libs g++ binutils-gold clang \ llvm8-libs llvm8-static llvm8-dev \ - cmake ninja zlib-dev curl-dev curl-static openssl-dev git make + cmake ninja zlib-dev curl-dev curl-static openssl openssl-dev git make # build ldc2 ######################################################## diff --git a/ci/docker.build.sh b/ci/docker.build.sh index 5f30225f..72d2ce7f 100644 --- a/ci/docker.build.sh +++ b/ci/docker.build.sh @@ -2,4 +2,4 @@ set -e -u cd /core/ -dub build -c static --compiler=ldc2 +DFLAGS="-linker=bfd" dub build -c static --compiler=ldc2 diff --git a/dub.sdl b/dub.sdl index 6c5f18e0..f49daa11 100644 --- a/dub.sdl +++ b/dub.sdl @@ -22,9 +22,7 @@ configuration "static" { targetType "executable" versions "VibeDefaultMain" lflags "-lz" "-lssl" "-lcrypto" "-ldl" platform="posix" - - // gcc on alpine has issues with the ld.gold linker, use bfd instead - dflags "-linker=bfd" "-static" platform="posix" + dflags "-static" platform="posix" } configuration "library" { versions "VibeCustomMain" From a199ce7ea56a2a2abe9dea41be68cb9ed279b823 Mon Sep 17 00:00:00 2001 From: looked-at-me Date: Fri, 8 May 2020 03:45:38 +0000 Subject: [PATCH 3/7] Use packages instead for tools. --- ci/Dockerfile | 44 ++++---------------------------------------- 1 file changed, 4 insertions(+), 40 deletions(-) diff --git a/ci/Dockerfile b/ci/Dockerfile index ead50419..b8c40293 100644 --- a/ci/Dockerfile +++ b/ci/Dockerfile @@ -1,44 +1,8 @@ -FROM alpine:3.10 - -ENV DUB_BRANCH "v1.20.1" -ENV RDMD_BRANCH "v2.091.0" - -RUN apk add --no-cache llvm5-libs g++ binutils-gold clang \ - llvm8-libs llvm8-static llvm8-dev \ - cmake ninja zlib-dev curl-dev curl-static openssl openssl-dev git make - -# build ldc2 ######################################################## - -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 -RUN tar xf ldc-bin.tar.xz - -# TODO: use environment variable from travis for LDC version -ADD https://github.com/ldc-developers/ldc/releases/download/v1.21.0/ldc-1.21.0-src.tar.gz /ldc-src.tar.xz -RUN tar xf ldc-src.tar.xz - -RUN mkdir /ldc-1.21.0-src/build \ - && cd /ldc-1.21.0-src/build \ - && cmake -G Ninja .. -DCMAKE_BUILD_TYPE=Release \ - -DD_COMPILER=/ldc2-1.13.0-alpine-linux-x86_64/bin/ldmd2 \ - && ninja -j2 \ - && ninja install - -# build dub ########################################################## - -RUN git clone --single-branch --branch ${DUB_BRANCH} https://github.com/dlang/dub \ - && cd dub \ - && ldmd2 -run build.d \ - && cp bin/dub /usr/local/bin/ - -# build rdmd ######################################################### - -RUN git clone --single-branch --branch ${RDMD_BRANCH} https://github.com/dlang/tools \ - && cd tools \ - && sed -i "s|^DMD = .*$|DMD = ldmd2|" posix.mak \ - && sed -i "s|^INSTALL_DIR = .*$|INSTALL_DIR = $PWD|" posix.mak \ - && make -f posix.mak install \ - && cp bin/rdmd /usr/local/bin/ +FROM alpine:edge +RUN apk add --no-cache g++ binutils-gold clang \ + zlib-dev curl-dev curl-static openssl openssl-dev make git \ + ldc dub dtools-rdmd COPY docker.build.sh /docker.build.sh RUN chmod +x /docker.build.sh From 9f07c74e13fae62466b7ada363fea3f8975cd4d5 Mon Sep 17 00:00:00 2001 From: looked-at-me Date: Sat, 23 May 2020 18:13:29 +0000 Subject: [PATCH 4/7] Remove install of gold and remove DFLAGS. --- ci/Dockerfile | 2 +- ci/docker.build.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ci/Dockerfile b/ci/Dockerfile index b8c40293..8805860c 100644 --- a/ci/Dockerfile +++ b/ci/Dockerfile @@ -1,6 +1,6 @@ FROM alpine:edge -RUN apk add --no-cache g++ binutils-gold clang \ +RUN apk add --no-cache g++ clang \ zlib-dev curl-dev curl-static openssl openssl-dev make git \ ldc dub dtools-rdmd diff --git a/ci/docker.build.sh b/ci/docker.build.sh index 72d2ce7f..5f30225f 100644 --- a/ci/docker.build.sh +++ b/ci/docker.build.sh @@ -2,4 +2,4 @@ set -e -u cd /core/ -DFLAGS="-linker=bfd" dub build -c static --compiler=ldc2 +dub build -c static --compiler=ldc2 From b831ff74d111ac8f1a41c761ba4c3eff26b7e5f6 Mon Sep 17 00:00:00 2001 From: looked-at-me Date: Sat, 23 May 2020 19:09:23 +0000 Subject: [PATCH 5/7] Add static libraries. --- ci/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/Dockerfile b/ci/Dockerfile index 8805860c..daff1295 100644 --- a/ci/Dockerfile +++ b/ci/Dockerfile @@ -1,7 +1,7 @@ FROM alpine:edge RUN apk add --no-cache g++ clang \ - zlib-dev curl-dev curl-static openssl openssl-dev make git \ + zlib-dev zlib-static curl-dev curl-static openssl openssl-dev openssl-libs-static \ ldc dub dtools-rdmd COPY docker.build.sh /docker.build.sh From 17cc190a43d3f85ae54ca1afdbed4e991d440421 Mon Sep 17 00:00:00 2001 From: looked-at-me Date: Sat, 23 May 2020 19:15:35 +0000 Subject: [PATCH 6/7] Remove dub folder. --- ci/docker.build.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ci/docker.build.sh b/ci/docker.build.sh index 5f30225f..1821dd4b 100644 --- a/ci/docker.build.sh +++ b/ci/docker.build.sh @@ -3,3 +3,7 @@ set -e -u cd /core/ dub build -c static --compiler=ldc2 + +# remove dub folder generated with build +# as it has root permissions from docker in the build folder +rm -rf ./.dub/ From 35af2ab1278c8a8b110ca92dac436c25c292a773 Mon Sep 17 00:00:00 2001 From: looked-at-me <61636119+looked-at-me@users.noreply.github.com> Date: Sat, 11 Jul 2020 22:16:09 -0400 Subject: [PATCH 7/7] Update ci/Dockerfile Co-authored-by: Mathias LANG --- ci/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/Dockerfile b/ci/Dockerfile index daff1295..7117c767 100644 --- a/ci/Dockerfile +++ b/ci/Dockerfile @@ -1,4 +1,4 @@ -FROM alpine:edge +FROM alpine:3.12 RUN apk add --no-cache g++ clang \ zlib-dev zlib-static curl-dev curl-static openssl openssl-dev openssl-libs-static \