From 7aec0bc54a52190b3dcc419f6d9aae95a6161ad7 Mon Sep 17 00:00:00 2001 From: Metalcape Date: Mon, 20 Mar 2023 18:47:53 +0100 Subject: [PATCH 1/4] Install patched knockd in `install-packages.sh` Use a binary built with musl for alpine --- Dockerfile | 14 +++++++------- build/alpine/install-packages.sh | 5 +++++ build/ol/install-packages.sh | 7 +++++++ build/ubuntu/install-packages.sh | 8 ++++++++ 4 files changed, 27 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index d1141cd7f7a..7f4e45c9dad 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,11 +3,17 @@ ARG BASE_IMAGE=eclipse-temurin:17-jre-focal FROM ${BASE_IMAGE} +# hook into docker BuildKit --platform support +# see https://docs.docker.com/engine/reference/builder/#automatic-platform-args-in-the-global-scope +ARG TARGETOS +ARG TARGETARCH +ARG TARGETVARIANT + # CI system should set this to a hash or git revision of the build directory and it's contents to # ensure consistent cache updates. ARG BUILD_FILES_REV=1 RUN --mount=target=/build,source=build \ - REV=${BUILD_FILES_REV} /build/run.sh install-packages + REV=${BUILD_FILES_REV} TARGET=${TARGETARCH}${TARGETVARIANT} /build/run.sh install-packages RUN --mount=target=/build,source=build \ REV=${BUILD_FILES_REV} /build/run.sh setup-user @@ -16,12 +22,6 @@ COPY --chmod=644 files/sudoers* /etc/sudoers.d EXPOSE 25565 -# hook into docker BuildKit --platform support -# see https://docs.docker.com/engine/reference/builder/#automatic-platform-args-in-the-global-scope -ARG TARGETOS -ARG TARGETARCH -ARG TARGETVARIANT - ARG EASY_ADD_VER=0.7.1 ADD https://github.com/itzg/easy-add/releases/download/${EASY_ADD_VER}/easy-add_${TARGETOS}_${TARGETARCH}${TARGETVARIANT} /usr/bin/easy-add RUN chmod +x /usr/bin/easy-add diff --git a/build/alpine/install-packages.sh b/build/alpine/install-packages.sh index 4c116915e29..c3f8da712e2 100755 --- a/build/alpine/install-packages.sh +++ b/build/alpine/install-packages.sh @@ -25,3 +25,8 @@ apk add --no-cache -U \ zstd \ nfs-utils \ libpcap + +# Patched knockd +cd /tmp && wget https://github.com/Metalcape/knock/releases/download/0.8.1/knock-0.8.1-alpine-amd64.tar.gz +tar -xf /tmp/knock-0.8.1-alpine-amd64.tar.gz -C /usr/local/ +ln -s /usr/local/sbin/knockd /usr/sbin/knockd diff --git a/build/ol/install-packages.sh b/build/ol/install-packages.sh index eab5e562262..24ed9ea454b 100755 --- a/build/ol/install-packages.sh +++ b/build/ol/install-packages.sh @@ -1,5 +1,7 @@ #!/bin/bash +export TARGET + set -e microdnf install dnf -y @@ -36,3 +38,8 @@ dnf install -y ImageMagick \ libpcap bash /build/ol/install-gosu.sh + +# Patched knockd +wget -O /tmp/knock.tar.gz https://github.com/Metalcape/knock/releases/download/0.8.1/knock-0.8.1-$TARGET.tar.gz +tar -xf /tmp/knock.tar.gz -C /usr/local/ && rm /tmp/knock.tar.gz +ln -s /usr/local/sbin/knockd /usr/sbin/knockd diff --git a/build/ubuntu/install-packages.sh b/build/ubuntu/install-packages.sh index d7b882258e7..cf1d2000a4c 100755 --- a/build/ubuntu/install-packages.sh +++ b/build/ubuntu/install-packages.sh @@ -1,5 +1,7 @@ #!/bin/sh +export TARGET + set -e apt-get update @@ -27,3 +29,9 @@ apt-get install -y \ libpcap0.8 apt-get clean + +# Patched knockd +wget -O /tmp/knock.tar.gz https://github.com/Metalcape/knock/releases/download/0.8.1/knock-0.8.1-$TARGET.tar.gz +tar -xf /tmp/knock.tar.gz -C /usr/local/ && rm /tmp/knock.tar.gz +ln -s /usr/local/sbin/knockd /usr/sbin/knockd +find /usr/lib -name 'libpcap.so.0.8' -execdir cp '{}' libpcap.so.1 \; From b8d52e1c339ecfe6118d5c3bda091f127a5b269a Mon Sep 17 00:00:00 2001 From: Metalcape Date: Tue, 21 Mar 2023 13:51:37 +0100 Subject: [PATCH 2/4] Remove old installation script --- Dockerfile | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7f4e45c9dad..dc4e7c2f31b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -52,11 +52,6 @@ RUN curl -fsSL ${MC_HELPER_BASE_URL}/mc-image-helper-${MC_HELPER_VERSION}.tgz \ | tar -C /usr/share -zxf - \ && ln -s /usr/share/mc-image-helper-${MC_HELPER_VERSION}/bin/mc-image-helper /usr/bin -# Install modified knockd -ADD https://github.com/Metalcape/knock/releases/download/0.8.1/knock-0.8.1-${TARGETARCH}${TARGETVARIANT}.tar.gz /tmp/knock.tar.gz -RUN tar -xf /tmp/knock.tar.gz -C /usr/local/ && rm /tmp/knock.tar.gz -RUN find /usr/lib -name 'libpcap.so.0.8' -execdir cp '{}' libpcap.so.1 \; - VOLUME ["/data"] WORKDIR /data From 40e11ff5b8f787db0d70710530a0e67b2b2aed6a Mon Sep 17 00:00:00 2001 From: Metalcape Date: Tue, 21 Mar 2023 14:36:49 +0100 Subject: [PATCH 3/4] make sure wget is installed in ubuntu --- build/ubuntu/install-packages.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build/ubuntu/install-packages.sh b/build/ubuntu/install-packages.sh index cf1d2000a4c..77c07075b24 100755 --- a/build/ubuntu/install-packages.sh +++ b/build/ubuntu/install-packages.sh @@ -26,7 +26,8 @@ apt-get install -y \ zstd \ lbzip2 \ nfs-common \ - libpcap0.8 + libpcap0.8 \ + wget apt-get clean From 9ea68d40313fdd4c5cf82e418dc732089d24b2e4 Mon Sep 17 00:00:00 2001 From: Metalcape Date: Tue, 21 Mar 2023 16:06:34 +0100 Subject: [PATCH 4/4] Use curl for downloading --- build/alpine/install-packages.sh | 4 ++-- build/ol/install-packages.sh | 2 +- build/ubuntu/install-packages.sh | 5 ++--- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/build/alpine/install-packages.sh b/build/alpine/install-packages.sh index c3f8da712e2..ee80f1be95e 100755 --- a/build/alpine/install-packages.sh +++ b/build/alpine/install-packages.sh @@ -27,6 +27,6 @@ apk add --no-cache -U \ libpcap # Patched knockd -cd /tmp && wget https://github.com/Metalcape/knock/releases/download/0.8.1/knock-0.8.1-alpine-amd64.tar.gz -tar -xf /tmp/knock-0.8.1-alpine-amd64.tar.gz -C /usr/local/ +curl -o /tmp/knock.tar.gz https://github.com/Metalcape/knock/releases/download/0.8.1/knock-0.8.1-alpine-amd64.tar.gz +tar -xf /tmp/knock.tar.gz -C /usr/local/ && rm /tmp/knock.tar.gz ln -s /usr/local/sbin/knockd /usr/sbin/knockd diff --git a/build/ol/install-packages.sh b/build/ol/install-packages.sh index 24ed9ea454b..3f43840e3e7 100755 --- a/build/ol/install-packages.sh +++ b/build/ol/install-packages.sh @@ -40,6 +40,6 @@ dnf install -y ImageMagick \ bash /build/ol/install-gosu.sh # Patched knockd -wget -O /tmp/knock.tar.gz https://github.com/Metalcape/knock/releases/download/0.8.1/knock-0.8.1-$TARGET.tar.gz +curl -o /tmp/knock.tar.gz https://github.com/Metalcape/knock/releases/download/0.8.1/knock-0.8.1-$TARGET.tar.gz tar -xf /tmp/knock.tar.gz -C /usr/local/ && rm /tmp/knock.tar.gz ln -s /usr/local/sbin/knockd /usr/sbin/knockd diff --git a/build/ubuntu/install-packages.sh b/build/ubuntu/install-packages.sh index 77c07075b24..6f5e7dd0fc4 100755 --- a/build/ubuntu/install-packages.sh +++ b/build/ubuntu/install-packages.sh @@ -26,13 +26,12 @@ apt-get install -y \ zstd \ lbzip2 \ nfs-common \ - libpcap0.8 \ - wget + libpcap0.8 apt-get clean # Patched knockd -wget -O /tmp/knock.tar.gz https://github.com/Metalcape/knock/releases/download/0.8.1/knock-0.8.1-$TARGET.tar.gz +curl -o /tmp/knock.tar.gz https://github.com/Metalcape/knock/releases/download/0.8.1/knock-0.8.1-$TARGET.tar.gz tar -xf /tmp/knock.tar.gz -C /usr/local/ && rm /tmp/knock.tar.gz ln -s /usr/local/sbin/knockd /usr/sbin/knockd find /usr/lib -name 'libpcap.so.0.8' -execdir cp '{}' libpcap.so.1 \;