Skip to content

Commit

Permalink
Add support for Bookworm and ARM64, build all variants in script.
Browse files Browse the repository at this point in the history
  • Loading branch information
elonen committed Nov 22, 2023
1 parent 43a76f5 commit e142024
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 15 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
target/
Dockerfile
build-deb-in-docker.sh
*.deb
DEB/

9 changes: 4 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
FROM rust:1-bullseye

RUN cargo install cargo-deb
ARG DEBIAN_VER=bookworm
FROM rust:1-${DEBIAN_VER}

RUN apt-get -qy update
RUN apt-get -qy install lsb-release
RUN apt-get -qy install lsb-release libssl-dev
RUN cargo install cargo-deb

WORKDIR /root
RUN mkdir /root/OUTPUT
COPY . .

43 changes: 34 additions & 9 deletions build-deb-in-docker.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,41 @@
#!/bin/bash
set -e

IMG="ldap_authz_proxy-deb:latest"
is_arch_supported() {
local arch=$1
local deb=$2
docker build --platform linux/$arch - <<EOF
FROM rust:1-$deb
RUN echo "Testing architecture $arch"
EOF
}

for ARCH in amd64 arm64; do
for DEBIAN_VER in bookworm bullseye; do
if is_arch_supported $ARCH $DEBIAN_VER; then
echo "=== Building for $DEBIAN_VER:$ARCH ==="
IMG="ldap_authz_proxy-deb_${ARCH}:latest"
docker build --platform linux/${ARCH} --build-arg DEBIAN_VER=${DEBIAN_VER} -t ${IMG} .
docker run --platform linux/${ARCH} --rm -iv${PWD}:/root/OUTPUT ${IMG} bash -s << EOF
cd /root
cargo deb || exit 1
chown -v $(id -u):$(id -g) target/debian/*.deb
docker build -t $IMG .
docker run --rm -iv${PWD}:/root/OUTPUT $IMG sh -s << EOF
cd /root
cargo deb || exit 1
chown -v $(id -u):$(id -g) target/debian/*.deb
cp -va target/debian/*.deb OUTPUT/
echo "============ Done. Built for: ============="
lsb_release -a
for x in target/debian/*.deb; do
NEWFILE=\$(echo "\$x" | sed -E "s/(.*_)/\1${DEBIAN_VER}_/")
mv "\$x" "\$NEWFILE"
done
cp -va target/debian/*.deb OUTPUT/
echo "============ Done. Built for: ============="
lsb_release -a
EOF
else
echo "=== Platform availability test (is_arch_supported) failed for $DEBIAN_VER:$ARCH. Skipping it..."
fi
done
done

echo "=============== $(pwd) ==============="
ls -l *.deb
2 changes: 1 addition & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ pub(crate) fn parse_config(config_file: &str) -> Result<Vec<ConfigSection>, Erro
if seen_sections.contains(&section_name) {
bail!("Duplicate section [{}]", section_name);
} else {
seen_sections.insert(section_name.clone());
seen_sections.insert(section_name);
}

// Check that no unknown keys are set
Expand Down

0 comments on commit e142024

Please sign in to comment.