Skip to content

Instantly share code, notes, and snippets.

@briceburg
Created October 18, 2023 01:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save briceburg/17ec78ba12ddb03fe6485d3cfc354625 to your computer and use it in GitHub Desktop.
Save briceburg/17ec78ba12ddb03fe6485d3cfc354625 to your computer and use it in GitHub Desktop.
bin/build - Docker Image building shell wrapper
#!/usr/bin/env bash
set -eo pipefail
project_root="$(cd "$(dirname "$0")/.." ; pwd -P)"
default_env="prod"
default_src="Dockerfile"
default_tag="build:latest"
(
echo "Build Dir: ${BUILD_DIR:=$project_root}" >&2
echo "Build Env: ${BUILD_ENV:=$default_env}" >&2
echo "Build Src: ${BUILD_SRC:=$default_src}" >&2
echo "Build Tag: ${BUILD_TAG:=$default_tag}" >&2
echo -e "\nBuilding...\n" >&2
cd "$BUILD_DIR"
docker build -t "$BUILD_TAG" --target "$BUILD_ENV" -f "$BUILD_SRC" . \
--secret id=GITHUB_TOKEN,env=GITHUB_TOKEN \
--secret id=FOO,env=FOO
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment