@@ -4,10 +4,11 @@ set -e -o pipefail
44
55usage () {
66 cat << USAGE >&2
7- Usage: $( basename " $0 " ) [OPTIONS]
7+ Usage: $0 [OPTIONS]
88
99Options:
1010 -b, --builder <builder> Specify the builder (docker or kaniko).
11+ -e, --extra-args <arg=value> Specify additional build-args.
1112 -t, --target <target> Specify the target (build, test, debug or production).
1213 Default: production.
1314 -g, --tag <tag> Specify the tag.
@@ -16,8 +17,9 @@ Options:
1617 -h, --help Display this help message.
1718
1819Examples:
19- $( basename " $0 " ) -b docker -t my-image --tag latest
20- $( basename " $0 " ) --builder kaniko --target debug
20+ $0 -b docker -t test --tag latest
21+ $0 --builder kaniko --target debug
22+ $0 -g local -e UID=\$ UID -e GID=\$ GID -e BASE_IMAGE=scratch
2123
2224USAGE
2325 exit 1
@@ -30,16 +32,18 @@ main() {
3032}
3133
3234build_with_docker () {
33- " ${DRY_RUN} " docker buildx build \
35+ ${DRY_RUN} docker buildx build \
3436 -t " ${IMAGE_NAME} :${TAG} " \
37+ " ${BUILD_ARGS[@]} " \
3538 --target=" ${TARGET} " .
3639}
3740
3841build_with_kaniko () {
3942 KANIKO_IMG=" gcr.io/kaniko-project/executor:latest"
40- " ${DRY_RUN} " docker run -w /build \
43+ ${DRY_RUN} docker run -w /build \
4144 -v " $PWD " :/build \
4245 --rm \
46+ " ${BUILD_ARGS[@]} " \
4347 " ${KANIKO_IMG} " \
4448 -d " ${IMAGE_NAME} :${TAG} " \
4549 --target " ${TARGET} " \
@@ -54,6 +58,7 @@ parse_args() {
5458 opt=" $1 " ; shift
5559 case $opt in
5660 --builder|-b) BUILDER=" $1 " ; shift ; ;;
61+ --extra-args|-e) BUILD_ARGS+=( --build-arg " $1 " ); shift ; ;;
5762 --target|-t) TARGET=" $1 " ; shift ; ;;
5863 --tag|-g) TAG=" $1 " ; shift ; ;;
5964 --help|-h) usage; ;;
0 commit comments