-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild
More file actions
executable file
·70 lines (60 loc) · 1.3 KB
/
build
File metadata and controls
executable file
·70 lines (60 loc) · 1.3 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
#!/bin/sh
set -e
# Default config
PLATFORM="linux/arm64"
MODE="--load"
TAG="lambda-shell-runtime"
VERSION="${VERSION:-develop}"
VARIANTS="base tiny micro full"
# VARIANTS="base tiny"
# 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
;;
*)
# 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
TAGS="--tag $TAG:$VARIANT"
if [ -n "$VERSION" ]; then
TAGS="$TAGS --tag $TAG:$VARIANT-$VERSION"
fi
docker buildx build \
--platform "$PLATFORM" \
--provenance=false \
--secret id=github_token,env=GITHUB_TOKEN \
$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