mirror of
https://github.com/kanidm/kanidm.git
synced 2025-04-21 17:55:40 +02:00
build: Create daemon image from scratch (#3452)
This commit is contained in:
parent
3edee485dd
commit
266dc77536
|
@ -10,3 +10,4 @@ kanidmd/sampledata
|
||||||
Makefile
|
Makefile
|
||||||
target
|
target
|
||||||
test.db
|
test.db
|
||||||
|
Dockerfile
|
||||||
|
|
|
@ -54,20 +54,43 @@ RUN --mount=type=cache,id=cargo,target=/cargo \
|
||||||
--release; \
|
--release; \
|
||||||
sccache -s
|
sccache -s
|
||||||
|
|
||||||
|
# Find and copy dynamically linked libraries using ldd
|
||||||
|
# caveat: this actually partially runs the binary, so it doesn't work for cross-compilation
|
||||||
|
RUN <<EOF
|
||||||
|
mkdir -p /out/libs
|
||||||
|
mkdir -p /out/libs-root
|
||||||
|
ldd /usr/src/kanidm/target/release/kanidmd
|
||||||
|
ldd /usr/src/kanidm/target/release/kanidmd | grep -v 'linux-vdso.so' | awk '{print $(NF-1) " " $1}' | sort -u -k 1,1 | awk '{print "install", "-D", $1, (($2 ~ /^\//) ? "/out/libs-root" $2 : "/out/libs/" $2)}' | xargs -I {} sh -c {}
|
||||||
|
ls -Rla /out/libs
|
||||||
|
ls -Rla /out/libs-root
|
||||||
|
EOF
|
||||||
|
|
||||||
# ======================
|
# ======================
|
||||||
|
|
||||||
FROM repos
|
FROM scratch
|
||||||
RUN \
|
|
||||||
--mount=type=cache,id=zypp,target=/var/cache/zypp \
|
|
||||||
zypper install -y \
|
|
||||||
timezone \
|
|
||||||
openssl-3 \
|
|
||||||
sqlite3 \
|
|
||||||
pam
|
|
||||||
|
|
||||||
COPY --from=builder /usr/src/kanidm/target/release/kanidmd /sbin/
|
WORKDIR /
|
||||||
COPY --from=builder /usr/src/kanidm/server/core/static /hpkg
|
|
||||||
RUN chmod +x /sbin/kanidmd
|
# Copy root certs for tls into image
|
||||||
|
# You can also mount the certs from the host
|
||||||
|
# --volume /etc/ssl/certs:/etc/ssl/certs:ro
|
||||||
|
COPY --from=repos /etc/ssl/certs /etc/ssl/certs
|
||||||
|
|
||||||
|
# Copy our build
|
||||||
|
COPY --from=builder --chmod=0755 /usr/src/kanidm/target/release/kanidmd /sbin/
|
||||||
|
# Web assets
|
||||||
|
COPY --from=builder /usr/src/kanidm/server/core/static /hpkg/
|
||||||
|
|
||||||
|
# Copy fixed-path dynamic libraries to their position
|
||||||
|
COPY --from=builder /out/libs-root/ /
|
||||||
|
COPY --from=builder /out/libs/ /lib/
|
||||||
|
|
||||||
|
# Inform loader where to find libraries
|
||||||
|
# This is necessary because opensuse searches for libraries in /lib64 or /lib depending on the architecture, but we don't know which one we're on.
|
||||||
|
# Alternatively, we could symlink /lib64 to /lib, and /usr/lib64 to /usr/lib, etc.
|
||||||
|
# We could always fix this by invoking the loader on the host (which works in a cross build it seems), but this is easier.
|
||||||
|
# On debian, it always searches for libraries in /lib.
|
||||||
|
ENV LD_LIBRARY_PATH=/lib
|
||||||
|
|
||||||
WORKDIR /data
|
WORKDIR /data
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue