-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·35 lines (27 loc) · 849 Bytes
/
Copy pathbuild.sh
File metadata and controls
executable file
·35 lines (27 loc) · 849 Bytes
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
#!/bin/bash
set -e
# === INPUT ARGS ===
REGISTRY="$1"
NAMESPACE="$2"
IMAGE_NAME="$3"
CONTEXT_DIR="${4:-.}"
if [[ -z "$REGISTRY" || -z "$NAMESPACE" || -z "$IMAGE_NAME" ]]; then
echo "Usage: $0 <registry> <namespace> <image> [context]"
exit 1
fi
# === VERSION ===
version=$(node -p "require('./package.json').version")
image="$REGISTRY/$NAMESPACE/$IMAGE_NAME"
echo "Building: $image:$version (context: $CONTEXT_DIR)"
# === BUILD ===
docker build --network=host -t "$image:$version" "$CONTEXT_DIR"
# === TAG LOGIC ===
if [[ "$version" == *dev* || "$version" == *alpha* || "$version" == *beta* || "$version" == *rc* ]]; then
docker tag "$image:$version" "$image:dev"
docker push "$image:dev"
else
docker tag "$image:$version" "$image:latest"
docker push "$image:latest"
fi
# === ALWAYS PUSH VERSION ===
docker push "$image:$version"