-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpush.sh
executable file
·54 lines (45 loc) · 1.05 KB
/
push.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env bash
set -euo pipefail
usage() {
echo "Usage: $0 <dotnet-version>"
echo "Example: $0 6.0"
exit 1
}
get_arch() {
local arch
arch=$(uname -m)
case "$arch" in
x86_64) echo "amd64" ;;
aarch64) echo "arm64" ;;
arm64) echo "arm64" ;;
*) echo "unsupported" ;;
esac
}
build_docker_image() {
local dotnet_version=$1
local architecture=$2
local app_version=$3
local image_name="ghcr.io/tumble-for-kronox/tumble-backend-dotnet-${dotnet_version}-${architecture}:${app_version}"
echo "Building Docker image: $image_name"
if docker buildx build --platform=linux/amd64 -t "$image_name" . --push; then
echo "Successfully built and pushed: $image_name"
else
echo "Failed to build or push: $image_name" >&2
exit 1
fi
}
main() {
DOTNET_VERSION=$1
APP_VERSION=$2
if [[ -z "${3:-}" ]]; then
ARCH=$(get_arch)
else
ARCH=$3
fi
if [[ $ARCH == "unsupported" ]]; then
echo "Unsupported architecture: $(uname -m)" >&2
exit 1
fi
build_docker_image "$DOTNET_VERSION" "$ARCH" "$APP_VERSION"
}
main "$@"