-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.alpine
More file actions
108 lines (89 loc) · 4 KB
/
Copy pathDockerfile.alpine
File metadata and controls
108 lines (89 loc) · 4 KB
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
105
106
107
108
#-----------------------------------------------------------------------------
# Base container
# -----------------------------------------------------------------------------
FROM alpine:latest AS base
ENV TZ="Europe/Berlin"
ENV CHARSET="UTF-8"
ENV PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
RUN apk --no-cache upgrade \
&& apk add --no-cache bash curl gnupg ca-certificates tzdata
SHELL [ "/bin/bash", "-c" ]
CMD [ "/bin/bash" ]
# -----------------------------------------------------------------------------
# Build container
# -----------------------------------------------------------------------------
FROM base AS builder
# Remove infinite loop from symlink /usr/lib/jvm/default-jvm/jre
# since jre points to the current directory.
RUN apk add --no-cache \
cmake g++ gdb boost-dev gmp-dev mpfr-dev zlib-dev xz-dev \
python3 py3-pip py3-libxml2 wget \
make unzip zip gnuplot pigz libstdc++ coreutils linux-headers \
git openjdk21-jdk \
&& python3 -m pip install --break-system-packages --no-cache --upgrade pip setuptools \
&& rm /usr/lib/jvm/default-jvm/jre
# Build bazel and install openjdk11
ENV JAVA_HOME="/usr/lib/jvm/default-jvm"
ENV PATH="$JAVA_HOME/bin:$PATH"
ARG BAZEL_DOWNLOAD=https://github.com/bazelbuild/bazel/releases/download/8.2.1/bazel-8.2.1-dist.zip
RUN mkdir /tmp/bazel && cd /tmp/bazel \
&& curl -sLO ${BAZEL_DOWNLOAD} && unzip bazel-*-dist.zip && rm bazel-*-dist.zip \
&& EXTRA_BAZEL_ARGS="--host_cxxopt=-D_LARGEFILE64_SOURCE=1 --cxxopt=-D_LARGEFILE64_SOURCE=1" bash ./compile.sh \
&& cp /tmp/bazel/output/bazel /usr/local/bin/ \
&& rm -rf /tmp/bazel
ARG TBB_DOWNLOAD=https://github.com/uxlfoundation/oneTBB/archive/refs/tags/v2022.1.0.tar.gz
RUN mkdir /tmp/tbb && cd /tmp/tbb \
&& wget --no-verbose ${TBB_DOWNLOAD} && tar -xzf v*.tar.gz && rm v*.tar.gz \
&& cd oneTBB* \
&& cmake -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_COMPILE_WARNING_AS_ERROR=OFF -DTBB_TEST=OFF \
&& cmake --build build --parallel \
&& cmake --install build --prefix /usr \
&& rm -rf /tmp/tbb
WORKDIR /source
COPY libraries /source/libraries
COPY src /source/src
COPY test /source/test
COPY .bazelrc /source/.bazelrc
COPY MODULE.bazel /source/MODULE.bazel
ARG BUILD_TARGET="//src:freitest.stripped"
ARG BUILD_CONFIG="release"
ARG BUILD_ARGS=""
ARG TEST_BUILD="yes"
ARG TEST_RUN="yes"
ARG TEST_TARGET="//test:*"
ARG TEST_ARGS="--test_arg=--log_level=all"
ARG BAZEL_BUILD_ARGS=""
ARG BAZEL_TEST_ARGS="--test_output=all"
# Build and optionally run tests, then copy generated executable files
# to output directory for next stage.
RUN bazel --max_idle_secs=0 build --config=$BUILD_CONFIG --config=$BUILD_MARCH $BUILD_BAZEL_ARGS //src:$BUILD_SRC \
&& if [ "$BUILD_TESTS" = "yes" ]; then \
bazel --max_idle_secs=0 test --config=$BUILD_CONFIG --config=$BUILD_MARCH $BUILD_BAZEL_ARGS \
$([ "$RUN_TESTS" = "no" ] && echo "--build_tests_only") \
$BAZEL_TEST_ARGS $TEST_ARGS $TEST_TARGET; \
fi \
&& mkdir -p /output \
&& find bazel-bin/ -type f -mindepth 1 -maxdepth 2 -exec \
sh -c 'readelf -l "$1" 2>/dev/null | grep -qio 'executable' && cp "$1" "/output/$(basename $1)"' -- {} \; \
&& bazel clean --expunge \
&& rm -rf ~/.cache/bazel/
RUN mkdir -p /output/lib/ \
&& cp /usr/lib/lib{boost,tbb,gmp,mpfr,z,lzma,icu}*.so* /output/lib/
# -----------------------------------------------------------------------------
# Final container
# -----------------------------------------------------------------------------
FROM base AS runner
RUN apk add --no-cache python3 py3-libxml2 unzip zip gnuplot pigz
WORKDIR /freitest
COPY data /freitest/data
COPY scripts /freitest/scripts
COPY settings /freitest/settings
COPY test/data /freitest/test/data
# Copy built executables and libraries
COPY --from=builder /output/freitest /freitest/
COPY --from=builder /output/*Test /freitest/
COPY --from=builder /output/lib /freitest/lib/
WORKDIR /freitest
ENV PATH="/freitest:${PATH}"
ENV LD_LIBRARY_PATH="/freitest/lib"
CMD [ "/bin/bash" ]