#!/bin/bash

# This starts a Docker container using the release image (openshift/origin-release:golang-1.6)
# and syncs the local directory into that image. The default mode performs a 'git archive' of
# the current HEAD, so you get a reproducible environment. You can also set
# OS_BUILD_ENV_REUSE_VOLUME to a docker volume name to rsync (or docker cp) the contents of
# the current directory into the image.
#
# Examples:
#   # sync local dir into the volume and print the Docker create command
#   $ hack/env
#
#   # builds the current HEAD in the container
#   $ hack/env make
#
#   # builds the current HEAD and copy _output/releases back locally afterwards
#   $ OS_BUILD_ENV_PRESERVE=_output/releases hack/env make release
#
#   # run all update tasks and copy the api, pkg, and docs directories back out
#   $ OS_BUILD_ENV_PRESERVE=api:docs:pkg hack/env make update
#
#   # rsync the contents of the current directory into the 'local' docker volume
#   # and iteratively build
#   $ export OS_BUILD_ENV_REUSE_VOLUME=local
#   $ export OS_BUILD_ENV_DOCKER_ARGS='-e OS_VERSION_FILE= '
#   $ hack/env make # slow
#   $ hack/env make # fast!
#

# NOTE:   only committed code is built.
source "$(dirname "${BASH_SOURCE}")/lib/init.sh"

os::build::environment::run "$@"