From 56cf37d637c2072b30482ab7d7563c38b019409d Mon Sep 17 00:00:00 2001 From: James Blackwell Date: Fri, 12 Dec 2025 12:59:03 +0700 Subject: [PATCH] Give arguments to docker/build-dev.sh This command improves docker/build-dev.sh, providing a variety of arguments to assist building images -h for help -p push the build -r Specify a different registry, such as myname on dockerhub, or myregistry.local -a arch[,arch] cross build to one or more architectures; .e.g. -a linux/arm64,linux/amd64 --- CHANGELOG.md | 2 ++ docker/build-dev.sh | 72 +++++++++++++++++++++++++++++++++++++++------ 2 files changed, 65 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4716c250..67c27667 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +- Update docker/dev-build.sh to support private registries, multiple architectures and pushing. Now [@jdblack](https://github.com/jblack). Now you can do things like `dev-build.sh -p -r my.private.registry -a linux/arm64,linux/amd64`. + ## [0.14.0] - 2025-12-09 ### Added diff --git a/docker/build-dev.sh b/docker/build-dev.sh index b02c314e..61640814 100755 --- a/docker/build-dev.sh +++ b/docker/build-dev.sh @@ -1,11 +1,65 @@ -#!/bin/bash -docker build --build-arg BRANCH=dev -t dispatcharr/dispatcharr:dev -f Dockerfile .. +#!/bin/bash +set -e + +# Default values +VERSION=$(python3 -c "import sys; sys.path.append('..'); import version; print(version.__version__)") +REGISTRY="dispatcharr" # Registry or private repo to push to +IMAGE="dispatcharr" # Image that we're building +BRANCH="dev" +ARCH="" # Architectures to build for, e.g. linux/amd64,linux/arm64 +PUSH=false + +usage() { + cat <<- EOF + To test locally: + ./build-dev.sh + + To build and push to registry: + ./build-dev.sh -p + + To build and push to a private registry: + ./build-dev.sh -p -r myregistry:5000 + + To build for -both- x86_64 and arm_64: + ./build-dev.sh -p -a linux/amd64,linux/arm64 + + Do it all: + ./build-dev.sh -p -r myregistry:5000 -a linux/amd64,linux/arm64 +EOF +exit 0 +} + +# Parse options +while getopts "pr:a:b:i:h" opt; do + case $opt in + r) REGISTRY="$OPTARG" ;; + a) ARCH="--platform $OPTARG" ;; + b) BRANCH="$OPTARG" ;; + i) IMAGE="$OPTARG" ;; + p) PUSH=true ;; + h) usage ;; + \?) echo "Invalid option: -$OPTARG" >&2; exit 1 ;; + esac +done + +BUILD_ARGS="BRANCH=$BRANCH" + +echo docker build --build-arg $BUILD_ARGS $ARCH -t $IMAGE +docker build -f Dockerfile --build-arg $BUILD_ARGS $ARCH -t $IMAGE .. +docker tag $IMAGE $IMAGE:$BRANCH +docker tag $IMAGE $IMAGE:$VERSION + +if [ -z "$PUSH" ]; then + echo "Please run 'docker push -t $IMAGE:dev -t $IMAGE:${VERSION}' when ready" +else + for TAG in latest "$VERSION" "$BRANCH"; do + docker tag "$IMAGE" "$REGISTRY/$IMAGE:$TAG" + docker push -q "$REGISTRY/$IMAGE:$TAG" + done + echo "Images pushed successfully." +fi + + + -# Get version information -VERSION=$(python -c "import sys; sys.path.append('..'); import version; print(version.__version__)") -# Build with version tag -docker build --build-arg BRANCH=dev \ - -t dispatcharr/dispatcharr:dev \ - -t dispatcharr/dispatcharr:${VERSION} \ - -f Dockerfile ..