Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
124 lines (102 loc) · 4.3 KB
/
Copy pathDockerfile
File metadata and controls
124 lines (102 loc) · 4.3 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# syntax=docker/dockerfile:1.7
ARG UBUNTU_IMAGE=ubuntu:22.04@sha256:2edbbc5dc405e9612ba3584ce95480277e3eb374407b5505fe26f17df77c7dbc
FROM ${UBUNTU_IMAGE} AS brpc-build
ARG BRPC_REPOSITORY=https://github.com/lite-tx/brpc.git
ARG BRPC_SHA=5b61020a9533887bde2d8cc03f9306b6b7104906
ARG BUILD_JOBS=4
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
build-essential \
ca-certificates \
cmake \
git \
libgflags-dev \
libleveldb-dev \
nlohmann-json3-dev \
libprotobuf-dev \
libprotoc-dev \
libssl-dev \
ninja-build \
pkg-config \
protobuf-compiler \
zlib1g-dev \
&& rm -rf /var/lib/apt/lists/*
RUN git init /tmp/brpc \
&& git -C /tmp/brpc remote add origin "${BRPC_REPOSITORY}" \
&& git -C /tmp/brpc fetch --depth 1 origin "${BRPC_SHA}" \
&& git -C /tmp/brpc checkout --detach FETCH_HEAD \
&& test "$(git -C /tmp/brpc rev-parse HEAD)" = "${BRPC_SHA}"
RUN cmake -S /tmp/brpc -B /tmp/brpc/build -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/opt/brpc \
-DCMAKE_INSTALL_LIBDIR=lib \
-DBUILD_SHARED_LIBS=ON \
-DBUILD_BRPC_TOOLS=OFF \
-DBUILD_UNIT_TESTS=OFF \
-DWITH_DEBUG_SYMBOLS=OFF \
-DWITH_GLOG=OFF \
-DWITH_MESALINK=OFF \
-DWITH_SNAPPY=OFF \
&& cmake --build /tmp/brpc/build --parallel "${BUILD_JOBS}" \
&& cmake --install /tmp/brpc/build \
&& printf '%s\n' "${BRPC_SHA}" > /opt/brpc/SOURCE_COMMIT \
&& test "$(cat /opt/brpc/SOURCE_COMMIT)" = "${BRPC_SHA}" \
&& test -f /opt/brpc/lib/libbrpc.so
FROM brpc-build AS app-build
ARG BUILD_JOBS=4
ENV CMAKE_PREFIX_PATH=/opt/brpc
ENV PKG_CONFIG_PATH=/opt/brpc/lib/pkgconfig
ENV LD_LIBRARY_PATH=/opt/brpc/lib
WORKDIR /src/fluxgate
COPY . .
RUN cmake -S . -B build -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_PREFIX_PATH=/opt/brpc \
&& cmake --build build --parallel "${BUILD_JOBS}" \
--target fluxgate_node fluxgate_unit_tests
FROM app-build AS test
RUN ctest --test-dir /src/fluxgate/build --output-on-failure
FROM ${UBUNTU_IMAGE} AS runtime
ARG BRPC_SHA=5b61020a9533887bde2d8cc03f9306b6b7104906
LABEL org.opencontainers.image.title="FluxGate" \
org.opencontainers.image.description="FluxGate service gateway and traffic analytics node" \
io.fluxgate.brpc.source="https://github.com/lite-tx/brpc" \
io.fluxgate.brpc.commit="${BRPC_SHA}"
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
ca-certificates \
curl \
libgflags2.2 \
libleveldb1d \
libprotobuf23 \
libprotoc23 \
libssl3 \
zlib1g \
&& rm -rf /var/lib/apt/lists/* \
&& groupadd --system --gid 10001 fluxgate \
&& useradd --system --uid 10001 --gid 10001 --home-dir /nonexistent \
--shell /usr/sbin/nologin fluxgate \
&& install -d -o 10001 -g 10001 -m 0750 /var/lib/fluxgate \
&& install -d -o root -g root -m 0755 /usr/share/doc/fluxgate/third_party/nlohmann-json \
&& dpkg-query -W -f='${binary:Package}\t${Version}\n' \
> /usr/share/doc/fluxgate/runtime-dpkg-manifest.tsv
COPY --from=brpc-build /opt/brpc/lib/ /opt/brpc/lib/
COPY --from=brpc-build /opt/brpc/SOURCE_COMMIT /opt/brpc/SOURCE_COMMIT
COPY --from=brpc-build /tmp/brpc/LICENSE /usr/share/doc/fluxgate/third_party/brpc/LICENSE
COPY --from=brpc-build /tmp/brpc/NOTICE /usr/share/doc/fluxgate/third_party/brpc/NOTICE
COPY --from=brpc-build /usr/share/doc/nlohmann-json3-dev/copyright /usr/share/doc/fluxgate/third_party/nlohmann-json/copyright
COPY LICENSE /usr/share/doc/fluxgate/LICENSE
COPY THIRD_PARTY_NOTICES.md /usr/share/doc/fluxgate/THIRD_PARTY_NOTICES.md
COPY --from=test /src/fluxgate/build/fluxgate_node /usr/local/bin/fluxgate_node
RUN printf '%s\n' '/opt/brpc/lib' > /etc/ld.so.conf.d/brpc.conf \
&& ldconfig \
&& test -x /usr/local/bin/fluxgate_node \
&& test -s /usr/share/doc/fluxgate/LICENSE \
&& test -s /usr/share/doc/fluxgate/THIRD_PARTY_NOTICES.md \
&& test -s /usr/share/doc/fluxgate/third_party/nlohmann-json/copyright \
&& test -s /usr/share/doc/fluxgate/runtime-dpkg-manifest.tsv
USER 10001:10001
STOPSIGNAL SIGTERM
ENTRYPOINT ["/usr/local/bin/fluxgate_node"]