-
Notifications
You must be signed in to change notification settings - Fork 2
/
build_and_push.sh
executable file
·39 lines (31 loc) · 1.05 KB
/
build_and_push.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
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash
# Exit early if any command fails
set -e
# Print all commands
set -x
pwd
export CERTBOT_IMAGE_NAME="caprover/certbot-sleeping"
export CERTBOT_VERSION="v2.11.0"
PROCESSED_DOCKERFILE="DockerfileProcessed.release"
envsubst <Dockerfile >$PROCESSED_DOCKERFILE
# ensure you're not running it on local machine
if [ -z "$CI" ] || [ -z "$GITHUB_REF" ]; then
echo "Running on a local machine! Exiting!"
exit 127
else
echo "Running on CI"
fi
# BRANCH=$(git rev-parse --abbrev-ref HEAD)
# On Github the line above does not work, instead:
BRANCH=${GITHUB_REF##*/}
echo "on branch $BRANCH"
if [[ "$BRANCH" != "master" ]]; then
echo 'Not on master branch! Aborting script!'
exit 1
fi
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
export DOCKER_CLI_EXPERIMENTAL=enabled
docker buildx ls
docker buildx create --name mybuilder
docker buildx use mybuilder
docker buildx build --platform linux/amd64,linux/arm64,linux/arm -t $CERTBOT_IMAGE_NAME:$CERTBOT_VERSION -t $CERTBOT_IMAGE_NAME:latest -f $PROCESSED_DOCKERFILE --push .