-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-image
32 lines (21 loc) · 922 Bytes
/
build-image
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
#!/bin/bash
set -e
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
cd $DIR
## Set repo name and tag
REPO_NAME="newsday/carto-for-print"
BRANCH=`git branch | grep '^*' | sed 's/* //'`
TAG="build-$BRANCH-$(date '+%Y%m%d%H%M%S')"
## Build the image using the repo name, tag and passing in the env var and build version
# docker build -t "$REPO_NAME:$TAG" --build-arg ENV=$ENV --build-arg TARGETENV=$ENV --build-arg BUILD_VERSION=$TAG .
BUILDX_EXISTS=$(docker buildx ls | grep "carto-for-print" | wc -l)
if [ $BUILDX_EXISTS -eq 0 ]; then
docker buildx create --name carto-for-print --driver docker-container --use
fi
docker buildx build --push --platform linux/arm64/v8,linux/amd64 --tag "$REPO_NAME:$TAG" --tag "$REPO_NAME:latest" .
## wait 10 seconds
sleep 10
## push the image to docker hub
docker push "$REPO_NAME:$TAG"
## Let us know we're good
echo "BUILD COMPLETE: $REPO_NAME:$TAG"