53 lines
1.4 KiB
Bash
Executable File
53 lines
1.4 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Build Roc OCI images locally.
|
|
#
|
|
# Usage:
|
|
# ./scripts/build.sh [roc-version]
|
|
#
|
|
# Default ROC_VERSION is "0.0.0-alpha2".
|
|
# Uses podman by default. Override with: BUILD_CMD=docker ./scripts/build.sh
|
|
#
|
|
# Builds all three targets: base, dev, ci
|
|
# Tags each with the version and ":latest".
|
|
#
|
|
# Registry defaults to "git.roo.lol/jbrechtel".
|
|
# Override with: REGISTRY=localhost:5000 ./scripts/build.sh
|
|
|
|
set -euo pipefail
|
|
|
|
ROC_VERSION="${1:-0.0.0-alpha2}"
|
|
REGISTRY="${REGISTRY:-git.roo.lol/jbrechtel}"
|
|
BUILD_CMD="${BUILD_CMD:-podman}"
|
|
BUILD_FLAGS="-f Containerfile"
|
|
HERE="$(cd "$(dirname "$0")/.." && pwd)"
|
|
|
|
cd "$HERE"
|
|
|
|
echo "=== Building Roc OCI images (version=${ROC_VERSION}, registry=${REGISTRY}) ==="
|
|
echo ""
|
|
|
|
build_target() {
|
|
local target="$1"
|
|
local image_name="$2"
|
|
|
|
echo "--- Building ${target} (${REGISTRY}/${image_name}:${ROC_VERSION}) ---"
|
|
$BUILD_CMD build \
|
|
$BUILD_FLAGS \
|
|
--target "$target" \
|
|
--build-arg "ROC_VERSION=${ROC_VERSION}" \
|
|
-t "${REGISTRY}/${image_name}:${ROC_VERSION}" \
|
|
-t "${REGISTRY}/${image_name}:latest" \
|
|
.
|
|
echo ""
|
|
}
|
|
|
|
build_target base roc-tools-base
|
|
build_target dev roc-tools-dev
|
|
build_target ci roc-tools-ci
|
|
|
|
echo "=== All images built successfully ==="
|
|
echo ""
|
|
echo "Images:"
|
|
$BUILD_CMD images --format "table {{.Repository}}:{{.Tag}}\t{{.Size}}" \
|
|
| grep "${REGISTRY}/roc-tools"
|