-
Notifications
You must be signed in to change notification settings - Fork 16
/
Dockerfile
50 lines (48 loc) · 2.31 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
# libpfm dependency builder image
FROM ubuntu:24.04 as libpfm-builder
ENV DEBIAN_FRONTEND=noninteractive
RUN apt update && \
apt install -y build-essential git devscripts debhelper libncurses-dev && \
git clone -b smartwatts https://github.com/gfieni/libpfm4.git /root/libpfm4 && \
cd /root/libpfm4 && \
sed -i 's/CONFIG_PFMLIB_NOPYTHON=n/CONFIG_PFMLIB_NOPYTHON=y/' debian/rules && \
sed -i '/^Package: python-libpfm4$/,/^$/d' debian/control && \
fakeroot debian/rules binary
# sensor builder image (build tools + development dependencies):
FROM ubuntu:24.04 as sensor-builder
ENV DEBIAN_FRONTEND=noninteractive
ARG BUILD_TYPE=Debug
ARG MONGODB_SUPPORT=ON
RUN apt update && \
apt install -y build-essential git clang-tidy cmake pkg-config libczmq-dev libjson-c-dev libsystemd-dev uuid-dev && \
echo "${MONGODB_SUPPORT}" |grep -iq "on" && apt install -y libmongoc-dev || true
COPY --from=libpfm-builder /root/libpfm4*.deb /tmp/
RUN dpkg -i /tmp/libpfm4_*.deb /tmp/libpfm4-dev_*.deb && \
rm /tmp/*.deb
COPY . /usr/src/hwpc-sensor
RUN cd /usr/src/hwpc-sensor && \
GIT_TAG=$(git describe --tags --dirty 2>/dev/null || echo "unknown") \
GIT_REV=$(git rev-parse HEAD 2>/dev/null || echo "unknown") \
cmake -B build -DCMAKE_BUILD_TYPE="${BUILD_TYPE}" -DCMAKE_C_CLANG_TIDY="clang-tidy" -DWITH_MONGODB="${MONGODB_SUPPORT}" && \
cmake --build build --parallel $(getconf _NPROCESSORS_ONLN)
# sensor runner image (only runtime depedencies):
FROM ubuntu:24.04 as sensor-runner
ENV DEBIAN_FRONTEND=noninteractive
ARG BUILD_TYPE=Debug
ARG MONGODB_SUPPORT=ON
ARG FILE_CAPABILITY=CAP_SYS_ADMIN
RUN useradd -d /opt/powerapi -m powerapi && \
apt update && \
apt install -y libczmq4 libjson-c5 libcap2-bin && \
echo "${MONGODB_SUPPORT}" |grep -iq "on" && apt install -y libmongoc-1.0-0 || true && \
echo "${BUILD_TYPE}" |grep -iq "debug" && apt install -y libasan8 libubsan1 || true && \
rm -rf /var/lib/apt/lists/*
COPY --from=libpfm-builder /root/libpfm4*.deb /tmp/
RUN dpkg -i /tmp/libpfm4_*.deb && \
rm /tmp/*.deb
COPY --from=sensor-builder /usr/src/hwpc-sensor/build/hwpc-sensor /usr/bin/hwpc-sensor
RUN setcap "${FILE_CAPABILITY}+ep" /usr/bin/hwpc-sensor && \
setcap -v "${FILE_CAPABILITY}+ep" /usr/bin/hwpc-sensor
COPY docker/entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
CMD ["--help"]