-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild-enhanced
More file actions
executable file
·96 lines (87 loc) · 2.02 KB
/
build-enhanced
File metadata and controls
executable file
·96 lines (87 loc) · 2.02 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/bin/sh
set -e
# Default config
PLATFORM="linux/arm64"
MODE="--load"
TAG="lambda-shell-runtime"
VERSION="${VERSION:-develop}"
HTTP_CLI_VERSION="${HTTP_CLI_VERSION:-v1.0.1}"
VARIANTS="base tiny micro full"
REGISTRIES=""
# Parse arguments
while [ $# -gt 0 ]; do
case "$1" in
--platform)
PLATFORM="$2"
shift 2
;;
--tag)
TAG="$2"
shift 2
;;
--push)
MODE="--push"
shift
;;
--load)
MODE="--load"
shift
;;
--registry)
REGISTRIES="$REGISTRIES $2"
shift 2
;;
--ghcr)
REGISTRIES="$REGISTRIES ghcr.io/ql4b"
shift
;;
--public-ecr)
REGISTRIES="$REGISTRIES public.ecr.aws/l9f6r9f5"
shift
;;
*)
# Remaining arguments are variants
VARIANTS="$*"
break
;;
esac
done
for VARIANT in $VARIANTS; do
DOCKERFILE="./Dockerfile"
TARGET="$VARIANT"
[ "$VARIANT" = "base" ] && TARGET="base"
echo "Building $VARIANT ($DOCKERFILE) with platform $PLATFORM..."
# Build tags
if [ "$MODE" = "--push" ] && [ -n "$REGISTRIES" ]; then
# For push mode, only use registry tags
TAGS=""
for REGISTRY in $REGISTRIES; do
TAGS="$TAGS --tag $REGISTRY/$TAG:$VARIANT"
if [ -n "$VERSION" ]; then
TAGS="$TAGS --tag $REGISTRY/$TAG:$VARIANT-$VERSION"
fi
done
else
# For load mode, use local tags
TAGS="--tag $TAG:$VARIANT"
if [ -n "$VERSION" ]; then
TAGS="$TAGS --tag $TAG:$VARIANT-$VERSION"
fi
fi
docker buildx build \
--platform "$PLATFORM" \
--provenance=false \
--secret id=github_token,env=GITHUB_TOKEN \
--build-arg VERSION="$VERSION" \
--build-arg HTTP_CLI_VERSION="$HTTP_CLI_VERSION" \
$TAGS \
--file "$DOCKERFILE" \
${TARGET:+--target "$TARGET"} \
$MODE \
.
# Only do local tagging for --load mode if version wasn't already tagged
if [ -n "$VERSION" ] && [ "$MODE" = "--load" ]; then
echo "Tagging $TAG:$VARIANT-$VERSION"
docker tag $TAG:$VARIANT $TAG:$VARIANT-$VERSION
fi
done