41 lines
1.2 KiB
Bash
Executable File
41 lines
1.2 KiB
Bash
Executable File
#!/bin/bash
|
|
set -euo pipefail
|
|
|
|
# Configuration
|
|
REGISTRY="git.sschuhmann.de/sschuhmann/rehearshalhub"
|
|
COMPONENTS=("api" "web" "worker" "watcher")
|
|
|
|
# Get version from git tag
|
|
get_version() {
|
|
local tag=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
|
|
if [[ -z "$tag" ]]; then
|
|
echo "Error: No git tags found. Please create a tag first (e.g., git tag v1.0.0)" >&2
|
|
exit 1
|
|
fi
|
|
# Remove v prefix if present for semantic versioning
|
|
echo "${tag#v}"
|
|
}
|
|
|
|
# Main build and push function
|
|
build_and_push() {
|
|
local version=$1
|
|
echo "Building and pushing version: $version"
|
|
|
|
for component in "${COMPONENTS[@]}"; do
|
|
echo "Building $component..."
|
|
docker build -t "$REGISTRY/$component-$version" -f "$component/Dockerfile" --target production "$component"
|
|
|
|
echo "Pushing $component-$version..."
|
|
docker push "$REGISTRY/$component-$version"
|
|
|
|
# Also tag as latest for convenience
|
|
docker tag "$REGISTRY/$component-$version" "$REGISTRY/$component-latest"
|
|
docker push "$REGISTRY/$component-latest"
|
|
done
|
|
|
|
echo "All components built and pushed successfully!"
|
|
}
|
|
|
|
# Execute
|
|
VERSION=$(get_version)
|
|
build_and_push "$VERSION" |