Skip to content
This repository has been archived by the owner on Oct 19, 2023. It is now read-only.

Commit

Permalink
Only use -x flag when BUILDER_DEBUG_OUTPUT env var is set. (#349)
Browse files Browse the repository at this point in the history
Add some user friendly echo messages.
  • Loading branch information
Takashi Matsuo authored Aug 8, 2017
1 parent 4e5ba99 commit 175bf4e
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 6 deletions.
7 changes: 7 additions & 0 deletions builder/gen-dockerfile/src/Builder/GenFilesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ protected function envsFromRuntimeConfig()
? $this->appYaml['env_variables']
: [];
$maps = [
'builder_debug_output' => 'BUILDER_DEBUG_OUTPUT',
'document_root' => 'DOCUMENT_ROOT',
'enable_stackdriver_integration' => self::STACKDRIVER_INTEGRATION_ENV,
'front_controller_file' => 'FRONT_CONTROLLER_FILE',
Expand Down Expand Up @@ -212,6 +213,12 @@ protected function envsFromRuntimeConfig()
// Otherwise prepend the app dir.
$ret[$v] = self::APP_DIR . '/' . $runtimeConfig[$k];
}
} elseif ($v === 'BUILDER_DEBUG_OUTPUT') {
$ret[$v] = filter_var(
$runtimeConfig[$k], FILTER_VALIDATE_BOOLEAN
)
? 'true'
: 'false';
} else {
$ret[$v] = $runtimeConfig[$k];
}
Expand Down
13 changes: 11 additions & 2 deletions php-base/build-scripts/composer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,23 @@


# A shell script for installing dependencies with composer.
set -xe

if [ "${BUILDER_DEBUG_OUTPUT}" = "true" ]; then
set -xe
else
set -e
fi

DEFAULT_PHP_VERSION="7.1"

if [ -f ${APP_DIR}/composer.json ]; then
if [ -n "${DETECTED_PHP_VERSION}" ]; then
PHP_VERSION="${DETECTED_PHP_VERSION}"
else
echo "Detecting PHP version..."
# Extract php version from the composer.json.
CMD="php /build-scripts/detect_php_version.php ${APP_DIR}/composer.json"
PHP_VERSION=`su www-data -c "${CMD}"`
echo "PHP_VERSION: ${PHP_VERSION}"

if [ "${PHP_VERSION}" == "exact" ]; then
cat<<EOF
Expand Down Expand Up @@ -60,13 +65,17 @@ EOF
fi
fi

echo "Using PHP version: ${PHP_VERSION}"

# Workaround for https://github.com/docker/docker/issues/6047
# We want to remove when Container Builder starts to use newer Docker.
rm -rf ${APP_DIR}/vendor

echo "Install PHP extensions..."
# Auto install extensions
php -d auto_prepend_file='' /build-scripts/install_extensions.php ${APP_DIR}/composer.json ${PHP_DIR}/lib/conf.d/extensions.ini ${PHP_VERSION}

echo "Running composer..."
# Run Composer.
if [ -n "${GOOGLE_RUNTIME_RUN_COMPOSER_SCRIPT}" ]; then
NOSCRIPT=''
Expand Down
8 changes: 7 additions & 1 deletion php-base/build-scripts/lockdown.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.

set -xe
if [ "${BUILDER_DEBUG_OUTPUT}" = "true" ]; then
set -xe
else
set -e
fi

echo "Locking down the document root..."

# Lock down the DOCUMENT_ROOT
chown -R root.www-data ${DOCUMENT_ROOT}
Expand Down
8 changes: 7 additions & 1 deletion php-base/build-scripts/move-config-files.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.

set -xe
if [ "${BUILDER_DEBUG_OUTPUT}" = "true" ]; then
set -xe
else
set -e
fi

echo "Moving user supplied config files..."

# App specific piece of the nginx config file included in the http section.
if [ -n "${NGINX_CONF_HTTP_INCLUDE}" ]; then
Expand Down
11 changes: 9 additions & 2 deletions php-base/stackdriver-files/enable_stackdriver_integration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,15 @@
# limitations under the License.


# A shell script for installing composer
set -xe
# A shell script for enabling stackdriver integration

if [ "${BUILDER_DEBUG_OUTPUT}" = "true" ]; then
set -xe
else
set -e
fi

echo "Enabling stackdriver integration..."

# To start the batch daemon
cp /stackdriver-files/batch-daemon.conf /etc/supervisor/conf.d
Expand Down

0 comments on commit 175bf4e

Please sign in to comment.