forked from jekhokie/raspberry-noaa-v2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
buildnow.sh
executable file
·28 lines (20 loc) · 928 Bytes
/
buildnow.sh
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
#!/bin/bash
#
[[ "$1" != "" ]] && BRANCH="$1" || BRANCH="$(git branch --show-current)"
[[ "$BRANCH" == "main" ]] && TAG="latest" || TAG="$BRANCH"
[[ "$ARCHS" == "" ]] && ARCHS="linux/armhf,linux/arm64,linux/amd64"
BASETARGET1=ghcr.io/kx1t
BASETARGET2=kx1t
IMAGE1="$BASETARGET1/$(pwd | sed -n 's|.*/docker-\(.*\)|\1|p'):$TAG"
IMAGE2="$BASETARGET2/$(pwd | sed -n 's|.*/docker-\(.*\)|\1|p'):$TAG"
echo "press enter to start building $IMAGE1 and $IMAGE2 from $BRANCH"
read
starttime="$(date +%s)"
# rebuild the container
set -x
git pull -a
echo "$(TZ=UTC date +%Y%m%d-%H%M%S)_$(git rev-parse --short HEAD)_$(git branch --show-current)" > rootfs/.CONTAINER_VERSION
docker buildx build --compress --push $2 --platform $ARCHS --tag $IMAGE1 .
# [[ $? ]] && docker buildx build --compress --push $2 --platform $ARCHS --tag $IMAGE2 .
rm -f rootfs/.CONTAINER_VERSION
echo "Total build time: $(( $(date +%s) - starttime )) seconds"