Commit 261be2c9 authored by jan.koester's avatar jan.koester
Browse files

test

parent 90acb03e
Loading
Loading
Loading
Loading
Loading

.dockerignore

0 → 100644
+18 −0
Changes for .dockerignore: 18 added lines, 0 removed lines.
Original line number Diff line number Diff line
build/
build*/
out/
.vs/
.cache/
.git/
.kdev4/
.vscode/
bindings/nodejs/lib/
bindings/nodejs/prebuilds/
test/node_modules/
*.o
*.so
*.a
*.db
Dockerfile
Dockerfile.alpine
.dockerignore
+91 −68
Changes for Dockerfile: 91 added lines, 68 removed lines.
Original line number Diff line number Diff line
FROM node:alpine AS build
WORKDIR /build/alpine

RUN apk update --no-cache  && apk upgrade --no-cache
RUN apk add --no-cache cmake ninja clang alpine-sdk lua-aports sudo openssh-keygen fakeroot openssh-client yaml-dev brotli-dev json-c-dev util-linux-dev zlib-dev

RUN git clone https://tuxist.de/git/jan.koester/libcmdplus.git && \
    cd libcmdplus && cd ..
RUN mkdir libcmdplus/build
RUN cd libcmdplus/build && cmake ../ -G Ninja -DCMAKE_CXX_FLAGS="-fPIC" && ninja install

RUN git clone https://tuxist.de/git/tuxist/uuidplus.git && \
    cd uuidplus && cd ..
RUN mkdir uuidplus/build
RUN cd uuidplus/build && cmake ../ -G Ninja && ninja install

RUN git clone https://tuxist.de/git/jan.koester/libnetplus.git && \
    cd libnetplus && cd ..
RUN mkdir libnetplus/build
RUN cd libnetplus/build && cmake ../ -G Ninja && ninja install

RUN git clone https://tuxist.de/git/jan.koester/libhtmlpp.git && \
    cd libhtmlpp && cd ..
RUN mkdir libhtmlpp/build
RUN cd libhtmlpp/build && cmake ../ -G Ninja && ninja install

RUN git clone https://tuxist.de/git/jan.koester/libhttppp.git && \
    cd libhttppp && cd ..
RUN mkdir libhttppp/build
RUN cd libhttppp/build && cmake ../ -G Ninja && ninja install

RUN git clone https://tuxist.de/git/jan.koester/libconfplus.git && \
    cd libconfplus && cd ..
RUN mkdir libconfplus/build
RUN cd libconfplus/build && cmake ../ -G Ninja -DCMAKE_CXX_FLAGS="-fPIC" && ninja install

RUN git clone https://tuxist.de/git/tuxist/libparitypp.git && \
    cd libparitypp && cd .. && \
    mkdir libparitypp/build && \
    cd libparitypp/build && cmake ../ -G Ninja && ninja install

COPY . authdb
RUN mkdir authdb/docker-build
RUN cd authdb/docker-build && cmake ../ -G Ninja -DDATAPATH:PATH=/usr/local/share/authdb -DBUILD_BINDINGS=OFF -DBUILD_TESTING=OFF && ninja install 
RUN rm -r authdb/docker-build

USER root
FROM node:alpine
RUN addgroup authdb
RUN adduser authdb -h /var/lib/authdb -S -G authdb
RUN apk update && apk upgrade
RUN apk add --no-cache yaml brotli openssl json-c libuuid libstdc++
RUN mkdir /etc/authdb
RUN mkdir /usr/local/share/authdb

COPY data/*.html /usr/local/share/authdb
COPY data/*.js /usr/local/share/authdb
COPY data/*.css /usr/local/share/authdb

COPY --from=build /usr/local/bin/authdb /usr/local/bin
COPY --from=build /usr/local/lib /usr/local/lib

COPY data/docker-config.yaml /etc/authdb/config.yaml

RUN chown -R authdb:authdb /var/lib/authdb

CMD ["authdb","-f","true","-c","yaml://etc/authdb/config.yaml"]
# authdb container image
#
#   build:    tuxist/fenriros-devel  (every FenrirOS package: clang, cmake, ninja and the
#                                     libnetplus/libhttppp/libconfplus/libuuidp/... -dev packages)
#   runtime:  tuxist/fenriros        (minimal: systempp, fresh, rpm, dnf5)
#
#   docker build -t authdb .
#   docker run -d -v authdb-etc:/etc/authdb -v authdb-data:/var/lib/authdb -p 9090:9090 -p 389:389 authdb
#
# Every library authdb needs is a FenrirOS package, so unlike blogi nothing is fetched or
# built besides authdb itself. The Alpine image is Dockerfile.alpine.
#
# Use --build-arg IMAGE_PREFIX=registry.tuxist.de/tuxist/ (and FENRIROS_TAG) to pull the base
# images from another registry/namespace -- see DOCKER_PREFIX in systempp/build-chroot.sh.

ARG IMAGE_PREFIX=tuxist/
ARG FENRIROS_TAG=20261021

FROM ${IMAGE_PREFIX}fenriros-devel:${FENRIROS_TAG} AS build

WORKDIR /src/authdb
COPY . .

# authdb goes to /usr/local: docker-config.yaml's plugin path points there.
RUN cmake -S . -B build -G Ninja \
        -DCMAKE_BUILD_TYPE=Release \
        -DCMAKE_INSTALL_PREFIX=/usr/local \
        -DCMAKE_INSTALL_LIBDIR=lib \
        -DDATAPATH:PATH=/usr/local/share/authdb \
        -DBUILD_BINDINGS=OFF \
        -DBUILD_TESTING=OFF \
 && cmake --build build \
 && DESTDIR=/stage cmake --install build \
 && rm -rf /stage/usr/local/include /stage/usr/local/lib/cmake \
 && find /stage -name '*.a' -exec rm -f {} + \
 && install -Dm644 data/docker-config.yaml /stage/usr/local/share/authdb/docker-config.yaml \
 && install -Dm755 docker/entrypoint.sh /stage/usr/libexec/authdb/entrypoint.sh

# fenriros only carries the base system, so copy the shared libraries authdb needs
# (DT_NEEDED, resolved recursively against the build image) into the stage, plus the
# confplus backends, which are dlopen()'d and so never show up as DT_NEEDED (authdb's own
# plugins are already in the stage). Every stage file is scanned: fresh's find has no
# -perm -u+x, and readelf skips whatever is not ELF.
RUN set -e; \
    find_lib() { for d in /usr/lib /lib /usr/local/lib /stage/usr/local/lib /stage/usr/local/lib/authdb; do [ -e "$d/$1" ] && { echo "$d/$1"; return 0; }; done; return 1; }; \
    mkdir -p /stage/usr/lib; \
    [ -d /usr/lib/confplus ] && cp -a /usr/lib/confplus /stage/usr/lib/; \
    todo=$(find /stage -type f); \
    seen=" "; \
    while [ -n "$todo" ]; do \
        next=""; \
        for f in $todo; do \
            for n in $(readelf -d "$f" 2>/dev/null | sed -n 's/.*(NEEDED).*\[\(.*\)\].*/\1/p'); do \
                case "$seen" in *" $n "*) continue ;; esac; \
                seen="$seen$n "; \
                p=$(find_lib "$n") || { echo "warning: $n (needed by $f) not found" >&2; continue; }; \
                case "$p" in /stage/*) continue ;; esac; \
                mkdir -p "/stage$(dirname "$p")"; \
                cp -L "$p" "/stage$p"; \
                next="$next /stage$p"; \
            done; \
        done; \
        todo=$next; \
    done

FROM ${IMAGE_PREFIX}fenriros:${FENRIROS_TAG} AS authdb

# Libraries the base image already ships (libc, libc++, ...) must win over the build image's
# copies of the same files, so only fill in what is missing.
COPY --from=build /stage/ /stage/
RUN set -e; \
    cd /stage; \
    find . ! -type d | while read -r f; do \
        t="/${f#./}"; \
        case "$t" in /usr/lib/*.so*|/lib/*.so*) [ -e "$t" ] && continue ;; esac; \
        mkdir -p "$(dirname "$t")"; \
        cp -a "$f" "$t"; \
    done; \
    cd /; rm -rf /stage; \
    useradd -d /var/lib/authdb authdb; \
    mkdir -p /etc/authdb /var/lib/authdb /var/log/authdb; \
    cp /usr/local/share/authdb/docker-config.yaml /etc/authdb/config.yaml; \
    chown -R authdb:authdb /var/lib/authdb /var/log/authdb

VOLUME ["/etc/authdb", "/var/lib/authdb", "/var/log/authdb"]

# web interface and API; LDAP of the AD plugin
EXPOSE 9090 389

ENTRYPOINT ["/usr/libexec/authdb/entrypoint.sh"]
CMD ["/usr/local/bin/authdb", "-f", "true", "-c", "yaml://etc/authdb/config.yaml"]

Dockerfile.alpine

0 → 100644
+68 −0
Changes for Dockerfile.alpine: 68 added lines, 0 removed lines.
Original line number Diff line number Diff line
FROM node:alpine AS build
WORKDIR /build/alpine

RUN apk update --no-cache  && apk upgrade --no-cache
RUN apk add --no-cache cmake ninja clang alpine-sdk lua-aports sudo openssh-keygen fakeroot openssh-client yaml-dev brotli-dev json-c-dev util-linux-dev zlib-dev

RUN git clone https://tuxist.de/git/jan.koester/libcmdplus.git && \
    cd libcmdplus && cd ..
RUN mkdir libcmdplus/build
RUN cd libcmdplus/build && cmake ../ -G Ninja -DCMAKE_CXX_FLAGS="-fPIC" && ninja install

RUN git clone https://tuxist.de/git/tuxist/uuidplus.git && \
    cd uuidplus && cd ..
RUN mkdir uuidplus/build
RUN cd uuidplus/build && cmake ../ -G Ninja && ninja install

RUN git clone https://tuxist.de/git/jan.koester/libnetplus.git && \
    cd libnetplus && cd ..
RUN mkdir libnetplus/build
RUN cd libnetplus/build && cmake ../ -G Ninja && ninja install

RUN git clone https://tuxist.de/git/jan.koester/libhtmlpp.git && \
    cd libhtmlpp && cd ..
RUN mkdir libhtmlpp/build
RUN cd libhtmlpp/build && cmake ../ -G Ninja && ninja install

RUN git clone https://tuxist.de/git/jan.koester/libhttppp.git && \
    cd libhttppp && cd ..
RUN mkdir libhttppp/build
RUN cd libhttppp/build && cmake ../ -G Ninja && ninja install

RUN git clone https://tuxist.de/git/jan.koester/libconfplus.git && \
    cd libconfplus && cd ..
RUN mkdir libconfplus/build
RUN cd libconfplus/build && cmake ../ -G Ninja -DCMAKE_CXX_FLAGS="-fPIC" && ninja install

RUN git clone https://tuxist.de/git/tuxist/libparitypp.git && \
    cd libparitypp && cd .. && \
    mkdir libparitypp/build && \
    cd libparitypp/build && cmake ../ -G Ninja && ninja install

COPY . authdb
RUN mkdir authdb/docker-build
RUN cd authdb/docker-build && cmake ../ -G Ninja -DDATAPATH:PATH=/usr/local/share/authdb -DBUILD_BINDINGS=OFF -DBUILD_TESTING=OFF && ninja install 
RUN rm -r authdb/docker-build

USER root
FROM node:alpine
RUN addgroup authdb
RUN adduser authdb -h /var/lib/authdb -S -G authdb
RUN apk update && apk upgrade
RUN apk add --no-cache yaml brotli openssl json-c libuuid libstdc++
RUN mkdir /etc/authdb
RUN mkdir /usr/local/share/authdb

COPY data/*.html /usr/local/share/authdb
COPY data/*.js /usr/local/share/authdb
COPY data/*.css /usr/local/share/authdb

COPY --from=build /usr/local/bin/authdb /usr/local/bin
COPY --from=build /usr/local/lib /usr/local/lib

COPY data/docker-config.yaml /etc/authdb/config.yaml

RUN chown -R authdb:authdb /var/lib/authdb

CMD ["authdb","-f","true","-c","yaml://etc/authdb/config.yaml"]
+1 −1
Changes for data/docker-config.yaml: 1 added line, 1 removed line.
Original line number Diff line number Diff line
AUTHDB:
    PLUGINS:
        PATH: "/usr/local/lib/authdb/plugins"
        PATH: "/usr/local/lib/authdb"
    PORT: 9090
    BIND: "0.0.0.0"
    MAXCONN: 1024

docker/entrypoint.sh

0 → 100755
+10 −0
Changes for docker/entrypoint.sh: 10 added lines, 0 removed lines.
Original line number Diff line number Diff line
#!/bin/sh
# FenrirOS's libc resolves names through /etc/resolv.yaml only, so translate the
# /etc/resolv.conf docker writes at container start (embedded DNS, --dns, ...).
if [ -r /etc/resolv.conf ]; then
    : > /etc/resolv.yaml
    while read -r key addr rest; do
        [ "$key" = nameserver ] && echo "- nameserver: \"$addr\"" >> /etc/resolv.yaml
    done < /etc/resolv.conf
fi
exec "$@"
Loading