Skip to content

Commit 571aa8c

Browse files
committed
WIP: moving the Dockerfiles used for the profiling images to scripts/docker/profiling
1 parent f6d1d3b commit 571aa8c

6 files changed

Lines changed: 339 additions & 10 deletions

File tree

scripts/docker/docker.mk

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,18 @@ CB_DIR:=$(dir $(realpath $(lastword $(MAKEFILE_LIST))))
1818
# Where the docker directories are
1919
DT:=$(CB_DIR)/build
2020

21+
# Where the profiling docker directories are
22+
PT:=$(CB_DIR)/profiling
23+
2124
# Location of top-level m4 template
2225
DOCKER_TMPL:=$(CB_DIR)/m4/Dockerfile.m4
2326

2427
# List of all the docker images (sorted for "docker.info")
2528
IMAGES:=$(sort $(patsubst $(DT)/%,%,$(wildcard $(DT)/*)))
2629

30+
# List of all profiling images (sorted)
31+
PROF_IMAGES:=$(sort $(patsubst $(PT)/%,%,$(wildcard $(PT)/*)))
32+
2733
# Don't use the Docker cache if asked
2834
ifneq "$(NOCACHE)" ""
2935
DOCKER_BUILD_OPTS += " --no-cache"
@@ -122,14 +128,29 @@ $(foreach IMAGE,$(IMAGES),\
122128
$(eval $(call CROSSBUILD_IMAGE_RULE,$(IMAGE))))
123129

124130
#
125-
# Build the LDAP image for profiling tests.
131+
# Define rules for building a profiling image
132+
#
133+
define PROFILING_IMAGE_RULE
134+
135+
.PHONY: docker.${1}.prof
136+
docker.${1}.prof:
137+
${Q}echo "BUILD ${1} ($(D_IPREFIX)/${1}-prof) from $(PT)/${1}/Dockerfile"
138+
139+
${Q}docker buildx build \
140+
$(DOCKER_BUILD_OPTS) \
141+
--progress=plain \
142+
. \
143+
-f $(PT)/${1}/Dockerfile \
144+
-t $(D_IPREFIX)/${1}-prof
145+
146+
endef
147+
148+
#
149+
# Add all the profiling image building rules
126150
#
127-
.PHONY: docker.openldap.build
128-
docker.openldap.build:
129-
${Q}echo "BUILD openldap:latest from $(DT)/openldap/Dockerfile"
130-
${Q}docker build \
131-
$(DT)/openldap \
132-
-t openldap:latest
151+
$(foreach IMAGE,$(PROF_IMAGES),\
152+
$(eval $(call PROFILING_IMAGE_RULE,$(IMAGE))))
153+
133154

134155
# if docker is defined
135156
endif
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
FROM debian:bookworm-slim
2+
3+
ARG DEBIAN_FRONTEND=noninteractive
4+
5+
RUN echo "slapd slapd/password1 password adminpassword" | debconf-set-selections \
6+
&& echo "slapd slapd/password2 password adminpassword" | debconf-set-selections \
7+
&& echo "slapd slapd/domain string example.com" | debconf-set-selections \
8+
&& echo "slapd shared/organization string Example" | debconf-set-selections \
9+
&& apt-get update \
10+
&& apt-get install -y --no-install-recommends slapd ldap-utils \
11+
&& apt-get clean \
12+
&& rm -rf /var/lib/apt/lists/*
13+
14+
COPY scripts/docker/profiling/openldap/users.ldif /etc/ldap/users.ldif
15+
16+
# Pre-populate the database during the build so the container is ready on start
17+
RUN slapd -h "ldapi:///" -u openldap -g openldap & \
18+
for i in $(seq 1 30); do \
19+
ldapsearch -x -H ldapi:/// -D "cn=admin,dc=example,dc=com" \
20+
-w adminpassword -b "dc=example,dc=com" > /dev/null 2>&1 && break; \
21+
sleep 1; \
22+
done && \
23+
ldapadd -x -H ldapi:/// -D "cn=admin,dc=example,dc=com" \
24+
-w adminpassword -f /etc/ldap/users.ldif && \
25+
kill "$(pidof slapd)" && \
26+
sleep 2
27+
28+
EXPOSE 389
29+
30+
CMD ["slapd", "-h", "ldap:///", "-u", "openldap", "-g", "openldap", "-d", "0"]
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
dn: ou=users,dc=example,dc=com
2+
objectClass: organizationalUnit
3+
ou: users
4+
5+
dn: uid=testuser,ou=users,dc=example,dc=com
6+
objectClass: inetOrgPerson
7+
objectClass: posixAccount
8+
objectClass: shadowAccount
9+
uid: testuser
10+
sn: User
11+
cn: testuser
12+
uidNumber: 10000
13+
gidNumber: 10000
14+
userPassword: testpass
15+
loginShell: /bin/bash
16+
homeDirectory: /home/testuser
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
# Auto generated for ubuntu24
2+
# from scripts/docker/m4/docker.deb.m4
3+
#
4+
# Rebuild this file with `make docker.ubuntu24.regen`
5+
#
6+
ARG from=ubuntu:24.04
7+
FROM ${from} AS build
8+
9+
ARG DEBIAN_FRONTEND=noninteractive
10+
11+
#
12+
# Install build tools
13+
#
14+
RUN apt-get update
15+
RUN apt-get install -y devscripts equivs git quilt gcc curl
16+
17+
#
18+
# Set up NetworkRADIUS extras repository
19+
#
20+
RUN install -d -o root -g root -m 0755 /etc/apt/keyrings \
21+
&& curl -o /etc/apt/keyrings/packages.networkradius.com.asc "https://packages.inkbridgenetworks.com/pgp/packages%40networkradius.com" \
22+
&& echo "deb [signed-by=/etc/apt/keyrings/packages.networkradius.com.asc] http://packages.networkradius.com/extras/ubuntu/noble noble main" > /etc/apt/sources.list.d/networkradius-extras.list \
23+
&& apt-get update
24+
25+
#
26+
# Create build directory
27+
#
28+
RUN mkdir -p /usr/local/src/repositories/freeradius-server
29+
WORKDIR /usr/local/src/repositories/freeradius-server/
30+
31+
#
32+
# Copy the FreeRADIUS directory in
33+
#
34+
COPY . .
35+
36+
#
37+
# Clean up tree - we want to build from the latest commit, not from
38+
# any cruft left around on the local system
39+
#
40+
RUN git clean -fdxx \
41+
&& git reset --hard HEAD
42+
43+
#
44+
# Build libkqueue from source on non-amd64 architectures.
45+
# The NetworkRADIUS extras repository only provides amd64 packages.
46+
#
47+
RUN if [ "$(dpkg --print-architecture)" != "amd64" ]; then \
48+
apt-get install -y cmake && \
49+
git clone --depth 1 https://github.com/mheily/libkqueue.git && \
50+
cd libkqueue && \
51+
cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_INSTALL_LIBDIR=lib . && \
52+
make && cpack -G DEB && dpkg -i *.deb && \
53+
cp *.deb /usr/local/src/repositories/ && \
54+
cd .. && rm -rf libkqueue; \
55+
fi
56+
57+
#
58+
# Install build dependencies
59+
# Debian sid fails if debian/control doesn't exist due to an issue
60+
# in one of the included make files, so we create a blank file.
61+
#
62+
RUN if [ -e ./debian/control.in ]; then \
63+
touch -t 202001010000 debian/control; \
64+
debian/rules debian/control; \
65+
fi; \
66+
echo 'y' | mk-build-deps -irt'apt-get -yV' debian/control
67+
68+
#
69+
# Build the server
70+
#
71+
RUN make -j$(nproc) deb
72+
73+
#
74+
# Clean environment and run the server
75+
#
76+
FROM ${from}
77+
ARG DEBIAN_FRONTEND=noninteractive
78+
79+
COPY --from=build /usr/local/src/repositories/*.deb /tmp/
80+
81+
#
82+
# Set up NetworkRADIUS extras repository
83+
# Reuse the signing key from the build stage instead of fetching it again
84+
#
85+
COPY --from=build /etc/apt/keyrings/packages.networkradius.com.asc /etc/apt/keyrings/packages.networkradius.com.asc
86+
RUN echo "deb [signed-by=/etc/apt/keyrings/packages.networkradius.com.asc] http://packages.networkradius.com/extras/ubuntu/noble noble main" > /etc/apt/sources.list.d/networkradius-extras.list
87+
88+
ARG freerad_uid=101
89+
ARG freerad_gid=101
90+
91+
RUN groupadd -g ${freerad_gid} -r freerad \
92+
&& useradd -u ${freerad_uid} -g freerad -r -M -d /etc/freeradius -s /usr/sbin/nologin freerad \
93+
&& apt-get update \
94+
&& apt-get install -y /tmp/*.deb \
95+
&& apt-get install -y \
96+
# Build essentials
97+
build-essential \
98+
cmake \
99+
make \
100+
git \
101+
vim \
102+
# SSL / compression / memory libs
103+
libssl-dev \
104+
libbrotli-dev \
105+
libtalloc-dev \
106+
# Google perf tools
107+
libgoogle-perftools-dev \
108+
google-perftools \
109+
# Valgrind / heap profiling
110+
valgrind \
111+
heaptrack \
112+
# Utilities
113+
less \
114+
psmisc \
115+
# kcachegrind - GUI callgrind viewer (requires display/X11 forwarding or VNC)
116+
# Pulls in heavy KDE/Qt dependencies (~200MB+).
117+
# To use: run with `docker run -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix`
118+
kcachegrind \
119+
kio \
120+
libkf5iconthemes5 \
121+
libkf5parts5 \
122+
libkf5textwidgets5 \
123+
libqt5gui5 \
124+
libqt5widgets5 \
125+
&& apt-get clean \
126+
&& rm -r /var/lib/apt/lists/* /tmp/*.deb \
127+
\
128+
&& ln -s /etc/freeradius /etc/raddb
129+
130+
WORKDIR /
131+
COPY scripts/docker/etc/docker-entrypoint.sh.deb docker-entrypoint.sh
132+
RUN chmod +x docker-entrypoint.sh
133+
134+
EXPOSE 1812/udp 1813/udp
135+
ENTRYPOINT ["/docker-entrypoint.sh"]
136+
CMD ["freeradius"]
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
# Auto generated for ubuntu24-prof
2+
# from scripts/docker/m4/crossbuild.deb.m4
3+
#
4+
# Rebuild this file with `make crossbuild.ubuntu24-prof.regen`
5+
#
6+
ARG from=ubuntu:24.04
7+
FROM ${from} AS build
8+
9+
SHELL ["/usr/bin/nice", "-n", "5", "/usr/bin/ionice", "-c", "3", "/bin/sh", "-x", "-c"]
10+
11+
ARG APT_OPTS="-y --option=Dpkg::options::=--force-unsafe-io --no-install-recommends"
12+
13+
ARG DEBIAN_FRONTEND=noninteractive
14+
15+
16+
#
17+
# Install add-apt-repository (may be needed for clang) and
18+
# package development utilities
19+
#
20+
RUN apt-get update && \
21+
apt-get install $APT_OPTS \
22+
# Build essentials
23+
build-essential \
24+
cmake \
25+
make \
26+
git \
27+
# SSL / compression / memory libs
28+
libssl-dev \
29+
libbrotli-dev \
30+
libtalloc-dev \
31+
# Google perf tools
32+
libgoogle-perftools-dev \
33+
google-perftools \
34+
# Valgrind / heap profiling
35+
valgrind \
36+
heaptrack \
37+
# Utilities
38+
less \
39+
psmisc \
40+
# kcachegrind - GUI callgrind viewer (requires display/X11 forwarding or VNC)
41+
# Pulls in heavy KDE/Qt dependencies (~200MB+).
42+
# To use: run with `docker run -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix`
43+
kcachegrind \
44+
kio \
45+
libkf5iconthemes5 \
46+
libkf5parts5 \
47+
libkf5textwidgets5 \
48+
libqt5gui5 \
49+
libqt5widgets5 \
50+
# Original build dependencies from the old Dockerfile, may be needed for some build steps
51+
devscripts \
52+
equivs \
53+
gnupg2 \
54+
lsb-release \
55+
procps \
56+
quilt \
57+
rsync \
58+
wget && \
59+
apt-get clean && \
60+
rm -r /var/lib/apt/lists/*
61+
62+
63+
#
64+
# Set up NetworkRADIUS extras repository
65+
#
66+
RUN install -d -o root -g root -m 0755 /etc/apt/keyrings && \
67+
wget -O /etc/apt/keyrings/packages.networkradius.com.asc "https://packages.networkradius.com/pgp/packages%40networkradius.com" && \
68+
echo "deb [signed-by=/etc/apt/keyrings/packages.networkradius.com.asc] http://packages.networkradius.com/extras/ubuntu/noble noble main" > /etc/apt/sources.list.d/networkradius-extras.list && \
69+
apt-get update
70+
71+
72+
#
73+
# Install compilers
74+
#
75+
RUN apt-get install $APT_OPTS \
76+
g++ \
77+
llvm clang lldb
78+
79+
80+
81+
82+
83+
#
84+
# Install some extra packages
85+
#
86+
RUN apt-get install $APT_OPTS \
87+
libnl-3-dev \
88+
libnl-genl-3-dev \
89+
gdb \
90+
less \
91+
lldb \
92+
vim \
93+
oathtool
94+
95+
96+
#
97+
# Setup a src dir in /usr/local
98+
#
99+
RUN mkdir -p /usr/local/src/repositories
100+
WORKDIR /usr/local/src/repositories
101+
102+
103+
#
104+
# Shallow clone the FreeRADIUS source
105+
#
106+
WORKDIR /usr/local/src/repositories
107+
ARG source=https://github.com/FreeRADIUS/freeradius-server.git
108+
RUN git clone --depth 1 --no-single-branch ${source}
109+
110+
#
111+
# Install build dependencies for all branches from v4 onwards
112+
# Debian sid fails if debian/control doesn't exist due to an issue
113+
# in one of the included make files, so we create a blank file.
114+
#
115+
WORKDIR freeradius-server
116+
RUN for i in $(git for-each-ref --format='%(refname:short)' refs/remotes/origin 2>/dev/null | sed -e 's#origin/##' | egrep "^(v[4-9]*\.[0-9x]*\.x|master|${branch})$" | sort -u); \
117+
do \
118+
git checkout $i; \
119+
if [ -e ./debian/control.in ] ; then \
120+
touch -t 202001010000 debian/control; \
121+
debian/rules debian/control ; \
122+
fi ; \
123+
mk-build-deps -irt"apt-get -o Debug::pkgProblemResolver=yes $APT_OPTS" debian/control ; \
124+
apt-get -y remove libiodbc2-dev ; \
125+
done

src/tests/multi-server/all.mk

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,13 +214,14 @@ test.multi-server.ci: $(TEST_MULTI_SERVER_CI_TESTS)
214214

215215
#
216216
# Ensure the ldap image is present before running prof-ldap tests.
217-
# Builds it automatically via docker.ldap.build if not found.
217+
# Builds it automatically via docker.openldap.prof if not found.
218218
#
219219
.PHONY: openldap.image
220220
openldap.image:
221-
${Q}if [ -z "$$(docker images -q openldap:latest 2>/dev/null)" ]; then \
222-
$(MAKE) -C $(top_srcdir) docker.openldap.build; \
221+
${Q}if [ -z "$$(docker images -q freeradius4/openldap-prof:latest 2>/dev/null)" ]; then \
222+
$(MAKE) -C $(top_srcdir) docker.openldap.prof; \
223223
fi
224+
${Q}docker tag freeradius4/openldap-prof:latest openldap:latest
224225

225226
$(TEST_MULTI_SERVER_TESTS.prof-ldap): openldap.image
226227

0 commit comments

Comments
 (0)