Skip to content

Commit 43e3432

Browse files
authored
Merge pull request #359 from continuouspipe/feature/magento1-public-location-auto
Replace magento1 APP_HOSTNAME/PUBLIC_ADDRESS with more standard autom…
2 parents 57a3c2e + 722f4af commit 43e3432

File tree

4 files changed

+36
-6
lines changed

4 files changed

+36
-6
lines changed

magento1/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,9 @@ Variable | Description | Expected values | Default
7676
--- | --- | --- | ----
7777
PHP_MEMORY_LIMIT | PHP memory limit | - | 768M
7878
PRODUCTION_ENVIRONMENT | If true, magento DI will be compiled | true/false | false
79-
APP_HOSTNAME | Web server's host name | \<projectname\>.docker | magento.docker
80-
PUBLIC_ADDRESS | Magento base URL. Note that an underscore should not be used due to magento admin login using PHP's filter_var to check for domain validity. "_" is not a valid character in a domain name. | https://\<projectname\>.docker/ | https://magento.docker/
79+
WEB_HOST | Web server's host name | \<projectname\>.docker | magento.docker
80+
PUBLIC_ADDRESS_UNSECURE | Magento unsecure base URL. Note that an underscore should not be used due to magento admin login using PHP's filter_var to check for domain validity. "_" is not a valid character in a domain name. | https://\<projectname\>.docker/ | https://$WEB_HOST/
81+
PUBLIC_ADDRESS_SECURE | Magento secure base URL. Note that an underscore should not be used due to magento admin login using PHP's filter_var to check for domain validity. "_" is not a valid character in a domain name. | https://\<projectname\>.docker/ | https://$WEB_HOST/
8182
FORCE_DATABASE_DROP | Drops the existing database before importing from assets | true/false | false
8283
DATABASE_NAME | Magento database name | - | magentodb
8384
DATABASE_USER | Magento database user | - | magento

magento1/usr/local/share/env/30-framework

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,12 @@ export MAGE_ROOT=${MAGE_ROOT:-${WEB_DIRECTORY}}
77
PRODUCTION_ENVIRONMENT=${PRODUCTION_ENVIRONMENT:-false}
88
PRODUCTION_ENVIRONMENT="$(convert_to_boolean_string "$PRODUCTION_ENVIRONMENT")"
99
export PRODUCTION_ENVIRONMENT
10-
export APP_HOSTNAME=${APP_HOSTNAME:-magento1.dev}
11-
export PUBLIC_ADDRESS=${PUBLIC_ADDRESS:-https://magento.docker/}
10+
11+
if [ -n "${APP_HOSTNAME:-}" ]; then
12+
echo 'deprecated: APP_HOSTNAME is deprecated, please use WEB_HOST instead' >&2
13+
export WEB_HOST="${APP_HOSTNAME}"
14+
fi
15+
export WEB_HOST=${WEB_HOST:-magento.docker}
1216

1317
FORCE_DATABASE_DROP=${FORCE_DATABASE_DROP:-false}
1418
FORCE_DATABASE_DROP="$(convert_to_boolean_string "$FORCE_DATABASE_DROP")"

magento1/usr/local/share/env/60-framework

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,28 @@
44
if ! [[ "$MAGE_ROOT" =~ ^/ ]]; then
55
export MAGE_ROOT=${WORK_DIRECTORY}/${MAGE_ROOT}
66
fi
7+
8+
if [ "$WEB_HTTPS_ONLY" == "true" ]; then
9+
PUBLIC_ADDRESS_UNSECURE_SCHEME=https
10+
else
11+
PUBLIC_ADDRESS_UNSECURE_SCHEME=http
12+
fi
13+
14+
if [ "$WEB_HTTPS" == "true" ] || [ "$WEB_HTTPS_OFFLOADED" == "true" ] || [ "$WEB_REVERSE_PROXIED" == "true" ]; then
15+
PUBLIC_ADDRESS_SECURE_SCHEME=https
16+
else
17+
PUBLIC_ADDRESS_SECURE_SCHEME=http
18+
fi
19+
20+
if [ -n "${PUBLIC_ADDRESS:-}" ]; then
21+
echo 'deprecated: PUBLIC_ADDRESS is deprecated, please set WEB_HOST or PUBLIC_ADDRESS_UNSECURE/PUBLIC_ADDRESS_SECURE instead' >&2
22+
23+
export PUBLIC_ADDRESS_UNSECURE=${PUBLIC_ADDRESS_UNSECURE:-$PUBLIC_ADDRESS}
24+
export PUBLIC_ADDRESS_SECURE=${PUBLIC_ADDRESS_SECURE:-$PUBLIC_ADDRESS}
25+
else
26+
export PUBLIC_ADDRESS_UNSECURE=${PUBLIC_ADDRESS_UNSECURE:-$PUBLIC_ADDRESS_UNSECURE_SCHEME://$WEB_HOST/}
27+
export PUBLIC_ADDRESS_SECURE=${PUBLIC_ADDRESS_SECURE:-$PUBLIC_ADDRESS_SECURE_SCHEME://$WEB_HOST/}
28+
29+
# for deprecated BC
30+
export PUBLIC_ADDRESS=${PUBLIC_ADDRESS_SECURE}
31+
fi

magento1/usr/local/share/magento1/magento_functions.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ function do_replace_core_config_values() {
5050
local SQL
5151
SQL="DELETE from core_config_data WHERE path LIKE 'web/%base_url';
5252
DELETE from core_config_data WHERE path LIKE 'system/full_page_cache/varnish%';
53-
INSERT INTO core_config_data VALUES (NULL, 'default', '0', 'web/unsecure/base_url', '$PUBLIC_ADDRESS');
54-
INSERT INTO core_config_data VALUES (NULL, 'default', '0', 'web/secure/base_url', '$PUBLIC_ADDRESS');
53+
INSERT INTO core_config_data VALUES (NULL, 'default', '0', 'web/unsecure/base_url', '$PUBLIC_ADDRESS_UNSECURE');
54+
INSERT INTO core_config_data VALUES (NULL, 'default', '0', 'web/secure/base_url', '$PUBLIC_ADDRESS_SECURE');
5555
INSERT INTO core_config_data VALUES (NULL, 'default', '0', 'system/full_page_cache/varnish/access_list', 'varnish');
5656
INSERT INTO core_config_data VALUES (NULL, 'default', '0', 'system/full_page_cache/varnish/backend_host', 'varnish');
5757
INSERT INTO core_config_data VALUES (NULL, 'default', '0', 'system/full_page_cache/varnish/backend_port', '80');

0 commit comments

Comments
 (0)