-
Notifications
You must be signed in to change notification settings - Fork 9
/
Dockerfile
104 lines (91 loc) · 3.65 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
FROM ubuntu:latest as base
LABEL MAINTAINER="DLang Tour Community <[email protected]>"
RUN apt-get update && apt-get install --no-install-recommends -y \
ca-certificates gpg \
curl \
gcc \
jq \
libc-dev \
libevent-dev \
liblapack-dev \
libopenblas-dev \
libssl-dev xz-utils \
clang libxml2 zlib1g-dev \
# 'llvm' is needed to get llvm-symbolizer symbol-->source line information in e.g. AddressSanitizer output
llvm \
&& update-alternatives --install "/usr/bin/ld" "ld" "/usr/bin/ld.gold" 20 \
&& update-alternatives --install "/usr/bin/ld" "ld" "/usr/bin/ld.bfd" 10
# set default libclang version
RUN ln -s /usr/lib/x86_64-linux-gnu/libclang-*.so.1 /usr/lib/x86_64-linux-gnu/libclang.so \
&& test -e /usr/lib/x86_64-linux-gnu/libclang.so
FROM base
ARG DLANG_VERSION=dmd
ARG DLANG_EXEC=dmd
ENV DLANG_VERSION=$DLANG_VERSION
ENV DLANG_EXEC=$DLANG_EXEC
# Download and run the install script
RUN curl -fsS -o /tmp/install.sh https://dlang.org/install.sh
RUN bash /tmp/install.sh -p /dlang install ${DLANG_VERSION}
# Fetch obj2asm from an older release if it's not included in the selected release
RUN set -eux ; \
if [ ! -f /dlang/*/linux/bin32/obj2asm ] ; \
then \
echo "Fetching missing obj2asm from an older release!" ; \
bash /tmp/install.sh -p /tmp/dlang-tools install dmd-2.093.1 ; \
if [ "${DLANG_EXEC}" = "dmd" ] ; \
then \
mv /tmp/dlang-tools/dmd-2.093.1/linux/bin32/obj2asm $(find -P /dlang/ -name bin32) ; \
mv /tmp/dlang-tools/dmd-2.093.1/linux/bin64/obj2asm $(find -P /dlang/ -name bin64) ; \
else \
mv /tmp/dlang-tools/dmd-2.093.1/linux/bin64/obj2asm $(find -P /dlang/ -name bin) ; \
fi ; \
\
rm -r /tmp/dlang-tools ; \
fi
COPY ./har /tmp/har/src
SHELL ["/bin/bash", "-c"]
RUN source /dlang/$(ls -tr /dlang | tail -n1)/activate; \
echo $PATH && \
$DMD -of=/tmp/har/src/har -g -debug /tmp/har/src/harmain.d /tmp/har/src/archive/har.d
# Clean up to keep the image size minimal
RUN rm -f /dlang/d-keyring.gpg \
&& rm -rf /dlang/dub* \
&& ln -s /dlang/$(ls -tr /dlang | tail -n1) /dlang/${DLANG_VERSION} \
&& mkdir -p /dlang/har && cp /tmp/har/src/har /dlang/har/har && rm -rf /tmp/har \
&& rm /tmp/install.sh \
&& rm /dlang/install.sh \
&& apt-get auto-remove -y xz-utils \
&& rm -rf /var/cache/apt \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \
&& find /dlang \( -type d -and \! -type l -and -path "*/bin32" -or -path "*/lib32" -or -path "*/html" \) | xargs rm -rf \
&& chmod 555 -R /dlang
ENV \
PATH=/dlang/${DLANG_VERSION}/linux/bin64:/dlang/dub:/dlang/${DLANG_VERSION}/bin:/dlang/har:${PATH} \
LD_LIBRARY_PATH=/dlang/${DLANG_VERSION}/linux/lib64:/dlang/${DLANG_VERSION}/lib \
LIBRARY_PATH=/dlang/${DLANG_VERSION}/linux/lib64:/dlang/${DLANG_VERSION}/lib
RUN useradd -d /sandbox d-user
RUN mkdir /sandbox && chown d-user:nogroup /sandbox
USER d-user
WORKDIR /sandbox
RUN dub build --compiler=${DLANG_EXEC} dpp
COPY packages.txt .
RUN packages=$(cat packages.txt) && \
for package_name in $packages; do \
package="$(echo $package_name | cut -d: -f1)"; \
version="$(echo $package_name | grep : |cut -d: -f2)"; \
version="${version:-*}"; \
echo -e '/++dub.sdl:\nname "foo"' > foo.d; \
echo -e "dependency \"${package}\" version=\"${version}\"" >> foo.d; \
echo -e '+/\nvoid main() {}' >> foo.d; \
dub build --single --compiler=${DLANG_EXEC} foo.d; \
version=$(dub describe ${package} | jq '.packages[0].version'); \
echo "${package}:${version}" >> packages; \
rm -f foo*; \
rm -rf .dub/build; \
done
USER root
COPY entrypoint.sh /entrypoint.sh
RUN mv /sandbox/packages /installed_packages; \
chmod 555 /installed_packages
USER d-user
ENTRYPOINT [ "/entrypoint.sh" ]