-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbuild.bash
More file actions
executable file
·66 lines (58 loc) · 1.79 KB
/
build.bash
File metadata and controls
executable file
·66 lines (58 loc) · 1.79 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
# Build and push the multi-architectrue images.
# Modify the following variables as appropraite when building new base inmages.
DOCKER_HUB_USER="braughtg"
IMAGE="vnc-novnc-base"
TAG="1.2.1"
PLATFORMS=linux/amd64,linux/arm64
# Check for the local build flag -d
LOCAL_BUILD=0
getopts 'd' opt 2> /dev/null
if [ $opt == 'd' ];
then
LOCAL_BUILD=1
fi
# Only check the login and make the builder if we are pushing the images.
if [ $LOCAL_BUILD == 0 ];
then
# Check that the DockerHub user identified above is logged in.
LOGGED_IN=$(docker-credential-desktop list | grep "$DOCKER_HUB_USER" | wc -l | cut -f 8 -d ' ')
if [ "$LOGGED_IN" == "0" ];
then
echo "Please log into Docker Hub as $DOCKER_HUB_USER before building images."
echo " Use: docker login"
echo "This allows multi architecture images to be pushed."
exit -1
fi
# Create a builder for this image if it doesn't exist.
BUILDER_NAME=vncbuilder
BUILDER=$(docker buildx ls | grep "$BUILDER_NAME" | wc -l | cut -f 8 -d ' ')
if [ "$BUILDER" == "0" ];
then
echo "Making new builder for $BUILDER_NAME images."
docker buildx create --name $BUILDER_NAME --driver docker-container --bootstrap
fi
# Switch to use the builder for this image.
docker buildx use $BUILDER_NAME
fi
# Print some info on the images
FULL_IMAGE_NAME=$DOCKER_HUB_USER/$IMAGE:$TAG
echo
echo "Buiding image: $IMAGE"
echo " With tag: $TAG"
if [ $LOCAL_BUILD == 1 ];
then
echo "Using Builder: building locally"
else
echo "For platforms: $PLATFORMS"
echo "Using builder: $BUILDER_NAME"
fi
echo " Pushing to: $DOCKER_HUB_USER"
echo " Full name: $FULL_IMAGE_NAME"
echo
if [ $LOCAL_BUILD == 1 ];
then
docker build -t $FULL_IMAGE_NAME .
else
# Build and push the images.
docker buildx build --platform $PLATFORMS -t $FULL_IMAGE_NAME --push .
fi