-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.ubuntu
More file actions
95 lines (79 loc) · 3.23 KB
/
Dockerfile.ubuntu
File metadata and controls
95 lines (79 loc) · 3.23 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
# -----------------------------------------------------------------------------
# Base container
# -----------------------------------------------------------------------------
FROM ubuntu:24.04 AS base
ENV DEBIAN_FRONTEND="noninteractive"
ENV TZ="Europe/Berlin"
RUN apt-get update \
&& apt-get upgrade -y \
&& apt-get install -y --no-install-recommends \
curl gnupg ca-certificates tzdata \
&& apt-get clean
SHELL [ "/bin/bash", "-c" ]
CMD [ "/bin/bash" ]
# -----------------------------------------------------------------------------
# Build container
# -----------------------------------------------------------------------------
FROM base AS builder
# Install compiler, build tools and required libraries
RUN curl -fsSL https://bazel.build/bazel-release.pub.gpg | gpg --dearmor > /etc/apt/trusted.gpg.d/bazel.gpg \
&& echo "deb [arch=amd64] https://storage.googleapis.com/bazel-apt stable jdk1.8" | tee /etc/apt/sources.list.d/bazel.list \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
g++ gdb libboost-all-dev libgmp-dev libmpfr-dev libz-dev xz-utils libtbb-dev \
python3 python3-libxml2 \
make bazel unzip zip gnuplot pigz \
git \
&& apt-get clean
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 $BAZEL_BUILD_ARGS $BUILD_TARGET -- $BUILD_ARGS \
&& if [ "$TEST_BUILD" = "yes" ]; then \
bazel --max_idle_secs=0 test --config=$BUILD_CONFIG $BAZEL_BUILD_ARGS \
$([ "$TEST_RUN" = "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 'ldd "$1" 2>/dev/null 1>&2 && cp "$1" "/output/$(basename $1)"' -- {} \; \
&& bazel clean --expunge \
&& rm -rf ~/.cache/bazel/
RUN mkdir -p /output/lib/ \
&& cp /usr/lib/x86_64-linux-gnu/lib{boost,tbb,gmp,mpfr,z,lzma,icu}*.so* /output/lib/
# -----------------------------------------------------------------------------
# Final container
# -----------------------------------------------------------------------------
FROM base AS runner
RUN apt-get update \
&& apt-get dist-upgrade -y \
&& apt-get install -y --no-install-recommends \
python3 python3-libxml2 unzip zip gnuplot pigz \
&& apt-get clean
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" ]