diff --git a/docker/Dockerfile b/docker/Dockerfile index 042c3d7a..3b28e350 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -5,8 +5,9 @@ WORKDIR /build ARG RELEASE_TAG=latest ARG TARGETPLATFORM ARG REPOSITORY=recyclarr/recyclarr +ARG BUILD_FROM_BRANCH -COPY --chmod=544 ./build.sh . +COPY --chmod=544 ./scripts/*.sh . RUN apk add unzip RUN ./build.sh diff --git a/docker/scripts/build-using-clone.sh b/docker/scripts/build-using-clone.sh new file mode 100644 index 00000000..42941018 --- /dev/null +++ b/docker/scripts/build-using-clone.sh @@ -0,0 +1,8 @@ +#!/bin/sh +set -ex + +git clone -b $BUILD_FROM_BRANCH "https://github.com/$REPOSITORY.git" source +cd source + +pwsh ./ci/Publish.ps1 $runtime +cp ./publish/$runtime/recyclarr .. diff --git a/docker/build.sh b/docker/scripts/build-using-release.sh similarity index 56% rename from docker/build.sh rename to docker/scripts/build-using-release.sh index 9aae38f0..f6d49b4e 100644 --- a/docker/build.sh +++ b/docker/scripts/build-using-release.sh @@ -9,14 +9,6 @@ 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 diff --git a/docker/scripts/build.sh b/docker/scripts/build.sh new file mode 100644 index 00000000..4042dc0e --- /dev/null +++ b/docker/scripts/build.sh @@ -0,0 +1,16 @@ +#!/bin/sh +set -ex + +# 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 + +if [ -z "$BUILD_FROM_BRANCH" ]; then + . ./build-using-release.sh +else + . ./build-using-clone.sh +fi