Skip to content

Commit f311544

Browse files
committed
prefix env variables with BUILDPACK_
Conflicts: bin/compile
1 parent 61a7b2a commit f311544

File tree

1 file changed

+33
-21
lines changed

1 file changed

+33
-21
lines changed

bin/compile

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,34 +18,46 @@ export_env_dir $3
1818

1919
# START CONFIG
2020

21-
# Support end-user configured NGINX_VERSION, PHP_VERSION, WORDPRESS_VERSION,
22-
# S3_BUCKET environment variables. This way, end-users
21+
# Support end-user configured BUILDPACK_NGINX_VERSION, BUILDPACK_PHP_VERSION, BUILDPACK_WORDPRESS_VERSION,
22+
# BUILDPACK_S3_BUCKET, BUILDPACK_WORDPRESS_DIR environment variables. This way, end-users
2323
# can choose exactly which versions to run with. Requires user-env-compile for now,
2424
# but will continue to work when Heroku deprecates user-env-compile and ENV_DIR
2525
# appears to this script as a parameter.
2626

27-
if [ -z "$NGINX_VERSION" ]; then
28-
NGINX_VERSION=1.4.2
27+
if [ -z "$BUILDPACK_NGINX_VERSION" ]; then
28+
BUILDPACK_NGINX_VERSION=1.4.2
2929
fi
3030

31-
if [ -z "$PHP_VERSION" ]; then
32-
PHP_VERSION=5.5.2
31+
if [ -z "$BUILDPACK_PHP_VERSION" ]; then
32+
BUILDPACK_PHP_VERSION=5.5.2
3333
fi
3434

35-
if [ -z "$WORDPRESS_VERSION" ]; then
36-
WORDPRESS_VERSION=3.9.1
35+
if [ -z "$BUILDPACK_WORDPRESS_VERSION" ]; then
36+
BUILDPACK_WORDPRESS_VERSION=3.9.1
3737
fi
3838

39-
if [ -z "$S3_BUCKET" ]; then
40-
S3_BUCKET=heroku-buildpack-wordpress
39+
if [ -z "$BUILDPACK_S3_BUCKET" ]; then
40+
BUILDPACK_S3_BUCKET=heroku-buildpack-wordpress
41+
fi
42+
43+
44+
# Prevent publishing if old environment variables set. This feature will be removed in the future
45+
# and thus the "global names" used before will be for application use.
46+
if [ -z "$NGINX_VERSION" || -z "$PHP_VERSION" || -z "$WORDPRESS_VERSION" || -z "$S3_BUCKET" || -z "$WORDPRESS_DIR" ]; then
47+
echo "Aborting. Env variables controlling buildpack should be prefixed with \"BUILDPACK_\"."
48+
echo "Rename the variables and push again. For example:"
49+
echo ""
50+
echo " heroku config:set BUILDPACK_WORDPRESS_VERSION"
51+
echo " heroku config:unset WORDPRESS_VERSION=x.x.x"
52+
exit 250
4153
fi
4254

4355
# END CONFIG
4456

4557
#
46-
NGINX_URL="https://s3.amazonaws.com/${S3_BUCKET}/nginx-${NGINX_VERSION}-heroku.tar.gz"
47-
PHP_URL="https://s3.amazonaws.com/${S3_BUCKET}/php-${PHP_VERSION}-with-fpm-heroku.tar.gz"
48-
WORDPRESS_URL="http://wordpress.org/wordpress-${WORDPRESS_VERSION}.tar.gz"
58+
NGINX_URL="https://s3.amazonaws.com/${BUILDPACK_S3_BUCKET}/nginx-${BUILDPACK_NGINX_VERSION}-heroku.tar.gz"
59+
PHP_URL="https://s3.amazonaws.com/${BUILDPACK_S3_BUCKET}/php-${BUILDPACK_PHP_VERSION}-with-fpm-heroku.tar.gz"
60+
WORDPRESS_URL="http://wordpress.org/wordpress-${BUILDPACK_WORDPRESS_VERSION}.tar.gz"
4961

5062
function indent() {
5163
c='s/^/ /'
@@ -62,32 +74,32 @@ mkdir -p $BUILD_DIR $CACHE_DIR
6274
# Nginx
6375
cd ${BUILD_DIR}
6476
if [ ! -d ./vendor/nginx ]; then
65-
echo "-----> Installing Nginx v${NGINX_VERSION}"
77+
echo "-----> Installing Nginx v${BUILDPACK_NGINX_VERSION}"
6678
mkdir -p ./vendor/nginx && cd ./vendor/nginx
6779
curl --silent --max-time 60 --location $NGINX_URL | tar xz
6880
fi
6981

7082
# PHP
7183
cd ${BUILD_DIR}
7284
if [ ! -d ./vendor/php ]; then
73-
echo "-----> Installing PHP v${PHP_VERSION}"
85+
echo "-----> Installing PHP v${BUILDPACK_PHP_VERSION}"
7486
mkdir -p ./vendor/php && cd ./vendor/php
7587
curl --silent --max-time 60 --location $PHP_URL | tar xz
7688
fi
7789

7890
# WordPress
79-
echo "-----> Installing WordPress v${WORDPRESS_VERSION}"
91+
echo "-----> Installing Wordpress v${BUILDPACK_WORDPRESS_VERSION}"
8092
cd ${BUILD_DIR}
8193
curl --silent --max-time 60 --location $WORDPRESS_URL | tar xz
8294

8395
# Support installation of WordPress into a subdirectory instead of the docroot
84-
if [ -n "$WORDPRESS_DIR" ]; then
85-
echo " Installing to subdirectory ${WORDPRESS_DIR}"
96+
if [ -n "$BUILDPACK_WORDPRESS_DIR" ]; then
97+
echo "-----> BUILDPACK_WORDPRESS_DIR is set to ${BUILDPACK_WORDPRESS_DIR}"
8698
mkdir "public"
87-
mv wordpress "public/$WORDPRESS_DIR"
88-
WORDPRESS_INSTALLATION_DIR="public/$WORDPRESS_DIR"
99+
mv wordpress "public/$BUILDPACK_WORDPRESS_DIR"
100+
WORDPRESS_INSTALLATION_DIR="public/$BUILDPACK_WORDPRESS_DIR"
89101
else
90-
echo " WORDPRESS_DIR not set. Installing WordPress to /"
102+
echo "-----> BUILDPACK_WORDPRESS_DIR not set. Installing WordPress to /"
91103
mv wordpress public
92104
WORDPRESS_INSTALLATION_DIR="public"
93105
fi

0 commit comments

Comments
 (0)