-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile.cli
More file actions
120 lines (102 loc) · 3.05 KB
/
Dockerfile.cli
File metadata and controls
120 lines (102 loc) · 3.05 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
# syntax=docker/dockerfile:1
# Control plane CLI tools for EJFAT
#
# This is a multi-stage build optimized for minimal image size
# Global build arguments (available to all stages)
ARG DEPS_VER=0.3.1
ARG E2SAR_DEPS_DEB=E2SAR-${DEPS_VER}-main-ubuntu-24.04/e2sar-deps_${DEPS_VER}_amd64.deb
ARG E2SAR_DEPS_DEB_URL=https://github.com/JeffersonLab/E2SAR/releases/download/${E2SAR_DEPS_DEB}
ARG E2SARINSTALL=/e2sar-install
#
# Stage 'build-base': image with build dependencies only
#
FROM ubuntu:24.04 AS build-base
# Import global ARGs into this stage
ARG E2SAR_DEPS_DEB_URL
ARG E2SARINSTALL
ENV DISTRO=ubuntu24
ENV HOME=/home/ubuntu
ENV LD_LIBRARY_PATH=/usr/local/lib
ENV PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
ENV PATH=/usr/local/bin:$PATH
ENV E2SARINSTALL=${E2SARINSTALL}
# Install all build dependencies in a single layer
RUN apt-get -yq update && \
apt-get -yq install --no-install-recommends \
python3 \
python3-pip \
python3-dev \
build-essential \
autoconf \
cmake \
libtool \
pkg-config \
libglib2.0-dev \
ninja-build \
openssl \
libssl-dev \
libsystemd-dev \
protobuf-compiler \
libre2-dev \
wget \
ca-certificates && \
pip3 install --break-system-packages pybind11 meson && \
wget -q -O boost_grpc.deb ${E2SAR_DEPS_DEB_URL} && \
dpkg -i ./boost_grpc.deb && \
rm -f ./boost_grpc.deb && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
#
# Stage 'compile'
#
FROM build-base AS compile
ARG E2SARINSTALL
WORKDIR /src
COPY . /src/
# create a build configuration and compile
RUN PATH=$HOME/.local/bin:/usr/local/bin:$PATH BOOST_ROOT=/usr/local/ LD_LIBRARY_PATH=${LD_LIBRARY_PATH} \
meson setup -Dpkg_config_path=${PKG_CONFIG_PATH} --prefix ${E2SARINSTALL} build && \
sed -i 's/-std=c++11//g' build/build.ninja && \
meson compile -C build -j 2 && \
meson install -C build
#
# Stage 'deploy': minimal runtime image
#
FROM ubuntu:24.04 AS deploy
# Import global ARGs into this stage
ARG E2SAR_DEPS_DEB_URL
ARG E2SARINSTALL
ENV LD_LIBRARY_PATH=/usr/local/lib
ENV E2SARINSTALL=${E2SARINSTALL}
ENV PATH=${E2SARINSTALL}/bin:/usr/local/bin:$PATH
# Install only runtime dependencies
RUN apt-get -yq update && \
apt-get -yq install --no-install-recommends \
ca-certificates \
wget \
libglib2.0-0 \
openssl \
libssl3 \
libsystemd0 \
libre2-10 \
libprotobuf32 \
netcat-traditional \
net-tools \
bc \
ethtool \
iproute2 \
iputils-ping \
gdb \
nano && \
wget -q -O boost_grpc.deb ${E2SAR_DEPS_DEB_URL} && \
dpkg -i ./boost_grpc.deb && \
rm -f ./boost_grpc.deb && \
apt-get purge -y wget && \
apt-get autoremove -y && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
WORKDIR ${E2SARINSTALL}
COPY --from=compile $E2SARINSTALL/bin $E2SARINSTALL/bin
COPY --from=compile $E2SARINSTALL/lib $E2SARINSTALL/lib
COPY --from=compile $E2SARINSTALL/include $E2SARINSTALL/include
CMD ["lbadm"]