From 7da161ce64cb67465a83c9115627bde46783c397 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beatrice=20Dellac=C3=A0?= Date: Wed, 26 Mar 2025 23:52:43 +0100 Subject: [PATCH] update multiarch build --- .drone.yml | 62 ++++++++++++++++++++---- Dockerfile => docker/Dockerfile.amd64 | 26 ++-------- docker/Dockerfile.arm64 | 69 +++++++++++++++++++++++++++ docker/manifest.tmpl | 12 +++++ 4 files changed, 139 insertions(+), 30 deletions(-) rename Dockerfile => docker/Dockerfile.amd64 (69%) create mode 100644 docker/Dockerfile.arm64 create mode 100644 docker/manifest.tmpl diff --git a/.drone.yml b/.drone.yml index 6269f65d3..ea2a468a5 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,26 +1,70 @@ +--- kind: pipeline type: kubernetes -name: build +name: linux-amd64 platform: os: linux arch: amd64 -# arch: arm64 - trigger: event: - push - steps: - name: docker image: plugins/docker settings: + dockerfile: docker/Dockerfile.amd64 username: from_secret: docker_username password: from_secret: docker_password repo: bottledpills/deluge-openvpn - tags: - - dev - platform: - - linux/amd64 - - linux/arm64 + auto_tag: true + auto_tag_suffix: linux-amd64 + +--- +kind: pipeline +type: kubernetes +name: linux-arm64 +platform: + os: linux + arch: arm64 +trigger: + event: + - push +steps: +- name: docker + image: plugins/docker + settings: + dockerfile: docker/Dockerfile.arm64 + username: + from_secret: docker_username + password: + from_secret: docker_password + repo: bottledpills/deluge-openvpn + auto_tag: true + auto_tag_suffix: linux-arm64 + +--- +kind: pipeline +type: kubernetes +name: manifest +platform: + os: linux + arch: amd64 +trigger: + event: + - push +steps: +- name: manifest + image: plugins/manifest + settings: + spec: docker/manifest.tmpl + username: + from_secret: docker_username + password: + from_secret: docker_password + auto_tag: true + ignore_missing: true +depends_on: + - linux-amd64 + - linux-arm64 \ No newline at end of file diff --git a/Dockerfile b/docker/Dockerfile.amd64 similarity index 69% rename from Dockerfile rename to docker/Dockerfile.amd64 index 2dc2c8326..9e1fb3c3a 100644 --- a/Dockerfile +++ b/docker/Dockerfile.amd64 @@ -9,28 +9,12 @@ RUN apt-get update && apt-get -y install curl software-properties-common # Step 2: Add the Deluge PPA and update apt cache RUN add-apt-repository -u ppa:deluge-team/stable && apt-get update -# Step 3: Download dumb-init asset based on architecture -RUN arch=$(dpkg --print-architecture) && \ - if [ "$arch" = "arm64" ]; then \ - asset="dumb-init_1.2.5_aarch64"; \ - elif [ "$arch" = "amd64" ]; then \ - asset="dumb-init_1.2.5_amd64.deb"; \ - else \ - echo "Unsupported architecture: $arch" && exit 1; \ - fi && \ - echo "Downloading dumb-init asset: $asset" && \ - curl -Lo /tmp/dumb-init "$DUMB_INIT_BASE_URL/$asset" +# Step 3: Download dumb-init asset for amd64 +RUN curl -Lo /tmp/dumb-init "$DUMB_INIT_BASE_URL/dumb-init_1.2.5_amd64.deb" -# Step 4: Install dumb-init based on asset type -RUN arch=$(dpkg --print-architecture) && \ - if [ "$arch" = "amd64" ]; then \ - dpkg-deb -x /tmp/dumb-init /tmp/dumb-init-dir && \ - cp /tmp/dumb-init-dir/usr/bin/dumb-init /usr/local/bin/dumb-init; \ - elif [ "$arch" = "arm64" ]; then \ - cp /tmp/dumb-init /usr/local/bin/dumb-init; \ - else \ - echo "Unsupported architecture: $arch" && exit 1; \ - fi && \ +# Step 4: Install dumb-init for amd64 +RUN dpkg-deb -x /tmp/dumb-init /tmp/dumb-init-dir && \ + cp /tmp/dumb-init-dir/usr/bin/dumb-init /usr/local/bin/dumb-init && \ chmod +x /usr/local/bin/dumb-init && \ rm -rf /tmp/dumb-init /tmp/dumb-init-dir diff --git a/docker/Dockerfile.arm64 b/docker/Dockerfile.arm64 new file mode 100644 index 000000000..af9c34f76 --- /dev/null +++ b/docker/Dockerfile.arm64 @@ -0,0 +1,69 @@ +FROM ubuntu:22.04 + +ARG DEBIAN_FRONTEND="noninteractive" +ENV DUMB_INIT_BASE_URL="https://github.com/Yelp/dumb-init/releases/download/v1.2.5" + +# Step 1: Install prerequisites +RUN apt-get update && apt-get -y install curl software-properties-common + +# Step 2: Add the Deluge PPA and update apt cache +RUN add-apt-repository -u ppa:deluge-team/stable && apt-get update + +# Step 3: Download dumb-init asset for arm64 +RUN curl -Lo /tmp/dumb-init "$DUMB_INIT_BASE_URL/dumb-init_1.2.5_aarch64" + +# Step 4: Install dumb-init for arm64 +RUN cp /tmp/dumb-init /usr/local/bin/dumb-init && \ + chmod +x /usr/local/bin/dumb-init && \ + rm -rf /tmp/dumb-init + +# Step 5: Install other dependencies +RUN apt-get -y install iputils-ping dnsutils bash jq net-tools openvpn curl ufw deluged deluge-web p7zip-full unrar unzip + +# Step 6: Clean up apt cache and temporary files +RUN rm -rf /tmp/* /var/lib/apt/lists/* /var/tmp/* + +# Step 7: Add the user "abc" +RUN groupmod -g 1000 users && \ + useradd -u 911 -U -d /config -s /bin/false abc && \ + usermod -G users abc + +# Step 8: Copy configuration and scripts +COPY root/ / + +# Step 9: Set environment variables +ENV OPENVPN_USERNAME=**None** \ + OPENVPN_PASSWORD=**None** \ + OPENVPN_PROVIDER=**None** \ + GLOBAL_APPLY_PERMISSIONS=true \ + TZ=Europe/Berlin \ + DELUGE_WEB_PORT=8112 \ + DELUGE_DEAMON_PORT=58846 \ + DELUGE_DOWNLOAD_DIR=/download/completed \ + DELUGE_INCOMPLETE_DIR=/download/incomplete \ + DELUGE_TORRENT_DIR=/download/torrents \ + DELUGE_WATCH_DIR=/download/watch \ + CREATE_TUN_DEVICE=true \ + ENABLE_UFW=false \ + UFW_ALLOW_GW_NET=false \ + UFW_EXTRA_PORTS= \ + UFW_DISABLE_IPTABLES_REJECT=false \ + PUID= \ + PGID= \ + UMASK=022 \ + PEER_DNS=true \ + PEER_DNS_PIN_ROUTES=true \ + DROP_DEFAULT_ROUTE= \ + HEALTH_CHECK_HOST=google.com \ + LOG_TO_STDOUT=false \ + DELUGE_LISTEN_PORT_LOW=53394 \ + DELUGE_LISTEN_PORT_HIGH=53404 \ + DELUGE_OUTGOING_PORT_LOW=63394 \ + DELUGE_OUTGOING_PORT_HIGH=63404 + +# Step 10: Configure health check and expose ports +HEALTHCHECK --interval=1m CMD /etc/scripts/healthcheck.sh +EXPOSE 8112 58846 + +# Step 11: Set default command +CMD ["/usr/local/bin/dumb-init", "/etc/openvpn/init.sh"] \ No newline at end of file diff --git a/docker/manifest.tmpl b/docker/manifest.tmpl new file mode 100644 index 000000000..ac18becd8 --- /dev/null +++ b/docker/manifest.tmpl @@ -0,0 +1,12 @@ +image: bottledpills/deluge-openvpn:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}latest{{/if}} +manifests: + - + image: bottledpills/deluge-openvpn:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-amd64 + platform: + architecture: amd64 + os: linux + - + image: bottledpills/deluge-openvpn:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm64 + platform: + architecture: arm64 + os: linux \ No newline at end of file