~nickbp/originz

ref: 5dd7b397fc6f03ffa881424b6d84e6de73605ac6 originz/docker-build.sh -rwxr-xr-x 581 bytes
5dd7b397Nick Parker Support filter params at the root config level again 1 year, 12 days ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/bin/bash

set -euo pipefail
IFS=$'\n\t'

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
cd $SCRIPT_DIR

PROJ_NAME=$(basename $SCRIPT_DIR)

DOCKER_REGISTRY=${DOCKER_REGISTRY:=docker.io}
DOCKER_REPOSITORY=${DOCKER_REPOSITORY:="nickbp/${PROJ_NAME}:"}
DOCKER_BUILD=${DOCKER_BUILD:="docker buildx build --push --platform linux/amd64,linux/arm64"}

# Get 7-character commit SHA (note: doesn't detect dirty commits)
COMMIT_SHA=$(git rev-parse HEAD | cut -b 1-7)

time /bin/sh -c "$DOCKER_BUILD -t ${DOCKER_REGISTRY}/${DOCKER_REPOSITORY}${COMMIT_SHA} ."