create build env for both dokku and new style buildpacks
This commit is contained in:
8
plugins/build-env/pre-build
Normal file → Executable file
8
plugins/build-env/pre-build
Normal file → Executable file
@@ -7,14 +7,22 @@ if [[ -f "$DOKKU_ROOT/ENV" ]]; then
|
|||||||
BUILD_ENV+=$(< "$DOKKU_ROOT/ENV")
|
BUILD_ENV+=$(< "$DOKKU_ROOT/ENV")
|
||||||
fi
|
fi
|
||||||
if [[ -f "$DOKKU_ROOT/BUILD_ENV" ]]; then
|
if [[ -f "$DOKKU_ROOT/BUILD_ENV" ]]; then
|
||||||
|
BUILD_ENV+=" "
|
||||||
BUILD_ENV+=$(< "$DOKKU_ROOT/BUILD_ENV")
|
BUILD_ENV+=$(< "$DOKKU_ROOT/BUILD_ENV")
|
||||||
fi
|
fi
|
||||||
if [[ -f "$DOKKU_ROOT/$APP/ENV" ]]; then
|
if [[ -f "$DOKKU_ROOT/$APP/ENV" ]]; then
|
||||||
|
BUILD_ENV+=" "
|
||||||
BUILD_ENV+=$(< "$DOKKU_ROOT/$APP/ENV")
|
BUILD_ENV+=$(< "$DOKKU_ROOT/$APP/ENV")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ! -z "$BUILD_ENV" ]]; then
|
if [[ ! -z "$BUILD_ENV" ]]; then
|
||||||
echo "-----> Adding BUILD_ENV to build environment..."
|
echo "-----> Adding BUILD_ENV to build environment..."
|
||||||
|
# create build env files for use in buildpacks like this: https://github.com/niteoweb/heroku-buildpack-buildout/blob/master/bin/compile#L34
|
||||||
|
id=$(echo $BUILD_ENV |sed 's@export @@g'| docker run -i -a stdin $IMAGE /bin/bash -c "for ENV_VAR in `cat`; do echo \$ENV_VAR |sed 's@^\([^=]*\)=\(.*\)\$@echo \2 >/tmp/env/\1@g' >>/tmp/set_env.sh; done && mkdir -p /tmp/env && /bin/bash /tmp/set_env.sh")
|
||||||
|
test $(docker wait $id) -eq 0
|
||||||
|
docker commit $id $IMAGE > /dev/null
|
||||||
|
|
||||||
|
# create build env for 'old style' buildpacks and dokku plugins
|
||||||
id=$(echo "$BUILD_ENV" | docker run -i -a stdin $IMAGE /bin/bash -c "cat >> /app/.env")
|
id=$(echo "$BUILD_ENV" | docker run -i -a stdin $IMAGE /bin/bash -c "cat >> /app/.env")
|
||||||
test $(docker wait $id) -eq 0
|
test $(docker wait $id) -eq 0
|
||||||
docker commit $id $IMAGE > /dev/null
|
docker commit $id $IMAGE > /dev/null
|
||||||
|
|||||||
Reference in New Issue
Block a user