From 0c30fed4d69572dcdbf2853ea251be846046b8d5 Mon Sep 17 00:00:00 2001 From: Robert Dailey Date: Fri, 3 Jun 2022 11:26:35 -0500 Subject: [PATCH] chore(docker): Move build logic to script file --- docker/Dockerfile | 25 +++---------------------- docker/build.sh | 22 ++++++++++++++++++++++ 2 files changed, 25 insertions(+), 22 deletions(-) create mode 100644 docker/build.sh diff --git a/docker/Dockerfile b/docker/Dockerfile index 9d57d306..eb75aafb 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -6,29 +6,10 @@ ARG RELEASE_TAG=latest ARG TARGETPLATFORM ARG REPOSITORY=recyclarr/recyclarr -RUN apk add unzip +COPY --chmod=544 ./build.sh . -RUN set -ex; \ - \ - # The download path is a bit different when using the latest release instead of a specific - # release - if [ "$RELEASE_TAG" = "latest" ]; then \ - download_path="latest/download"; \ - else \ - download_path="download/$RELEASE_TAG"; \ - fi; \ - \ - # Determine the runtime from the target platform provided by Docker Buildx - case "$TARGETPLATFORM" in \ - "linux/arm/v7") runtime="linux-musl-arm" ;; \ - "linux/arm64") runtime="linux-musl-arm64" ;; \ - "linux/amd64") runtime="linux-musl-x64" ;; \ - *) echo >&2 "ERROR: Unsupported target platform: $TARGETPLATFORM"; exit 1 ;; \ - esac; \ - \ - # Download and extract the recyclarr binary from the release - wget --quiet -O recyclarr.zip "https://github.com/$REPOSITORY/releases/$download_path/recyclarr-$runtime.zip"; \ - unzip recyclarr.zip; +RUN apk add unzip +RUN ./build.sh ############################################################################# FROM alpine diff --git a/docker/build.sh b/docker/build.sh new file mode 100644 index 00000000..9aae38f0 --- /dev/null +++ b/docker/build.sh @@ -0,0 +1,22 @@ +#!/bin/sh +set -ex + +# The download path is a bit different when using the latest release instead of a specific +# release +if [ "$RELEASE_TAG" = "latest" ]; then + download_path="latest/download"; +else + download_path="download/$RELEASE_TAG"; +fi + +# Determine the runtime from the target platform provided by Docker Buildx +case "$TARGETPLATFORM" in + "linux/arm/v7") runtime="linux-musl-arm" ;; + "linux/arm64") runtime="linux-musl-arm64" ;; + "linux/amd64") runtime="linux-musl-x64" ;; + *) echo >&2 "ERROR: Unsupported target platform: $TARGETPLATFORM"; exit 1 ;; +esac + +# Download and extract the recyclarr binary from the release +wget --quiet -O recyclarr.zip "https://github.com/$REPOSITORY/releases/$download_path/recyclarr-$runtime.zip" +unzip recyclarr.zip