feat: multi-architecture builds (x86_64 + arm64)
- build-rpm.sh: --arch flag for targeting x86_64 or arm64, --all for both Uses bun cross-compile with --target=bun-linux-x64/arm64 - build-bastion.sh: --arch flag for Docker platform targeting - release.sh: builds both architectures by default - CI: builds + publishes RPM/DEB for both architectures Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -11,14 +11,72 @@ if [ -f .env ]; then
|
||||
set -a; source .env; set +a
|
||||
fi
|
||||
|
||||
# ── Argument parsing ───────────────────────────────────────────────
|
||||
TARGET_ARCH=""
|
||||
|
||||
usage() {
|
||||
cat <<EOF
|
||||
Usage: $(basename "$0") [OPTIONS] [TAG]
|
||||
|
||||
Build bastion container image and optionally push to registry.
|
||||
|
||||
Options:
|
||||
--arch ARCH Target platform: x86_64 or arm64 (default: host arch)
|
||||
-h, --help Show this help message
|
||||
|
||||
Arguments:
|
||||
TAG Image tag (default: version from package.json)
|
||||
EOF
|
||||
exit 0
|
||||
}
|
||||
|
||||
POSITIONAL_ARGS=()
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--arch)
|
||||
TARGET_ARCH="$2"
|
||||
shift 2
|
||||
;;
|
||||
-h|--help)
|
||||
usage
|
||||
;;
|
||||
*)
|
||||
POSITIONAL_ARGS+=("$1")
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Registry defaults to internal address (external proxy has body size limit)
|
||||
REGISTRY="${GITEA_REGISTRY:-mysources.co.uk}"
|
||||
IMAGE="lab-bastion"
|
||||
VERSION=$(node -p "require('./package.json').version")
|
||||
TAG="${1:-$VERSION}"
|
||||
TAG="${POSITIONAL_ARGS[0]:-$VERSION}"
|
||||
|
||||
echo "==> Building bastion image (tag: $TAG)..."
|
||||
podman build -t "$IMAGE:$TAG" -f stack/Dockerfile .
|
||||
# ── Resolve target platform ───────────────────────────────────────
|
||||
detect_host_arch() {
|
||||
local machine
|
||||
machine="$(uname -m)"
|
||||
case "$machine" in
|
||||
x86_64) echo "x86_64" ;;
|
||||
aarch64) echo "arm64" ;;
|
||||
arm64) echo "arm64" ;;
|
||||
*) echo "$machine" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
docker_platform_for() {
|
||||
case "$1" in
|
||||
x86_64) echo "linux/amd64" ;;
|
||||
arm64) echo "linux/arm64" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
ARCH="${TARGET_ARCH:-$(detect_host_arch)}"
|
||||
PLATFORM="$(docker_platform_for "$ARCH")"
|
||||
|
||||
echo "==> Building bastion image (tag: $TAG, platform: $PLATFORM)..."
|
||||
podman build --platform "$PLATFORM" -t "$IMAGE:$TAG" -f stack/Dockerfile .
|
||||
|
||||
echo "==> Tagging as $REGISTRY/michal/$IMAGE:$TAG..."
|
||||
podman tag "$IMAGE:$TAG" "$REGISTRY/michal/$IMAGE:$TAG"
|
||||
@@ -41,3 +99,4 @@ fi
|
||||
|
||||
echo "==> Done!"
|
||||
echo " Image: $REGISTRY/michal/$IMAGE:$TAG"
|
||||
echo " Platform: $PLATFORM"
|
||||
|
||||
Reference in New Issue
Block a user