Skip to content
This repository was archived by the owner on Oct 1, 2020. It is now read-only.

Commit 8cb0e0b

Browse files
committed
Support multiple Magento instances simultaneously #52
1 parent 45e5a91 commit 8cb0e0b

23 files changed

+179
-268
lines changed

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
script:
1414
- cd tests && sudo bash ./NoCustomConfigBasicTest.sh
1515
- script: cd tests && sudo bash ./Ce23WithSampleDataMysqlSearchNoNfsTest.sh
16-
- script: cd tests && sudo bash ./CeFromComposerNoNfsTest.sh
16+
- script: cd tests && sudo bash ./MultiInstanceWithCeFromComposerNoNfsTest.sh
1717
- script: cd tests && sudo bash ./EeLinkingTest.sh
1818

1919
env:

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,8 @@ You can create multiple copies of [etc/instance/config.yaml.dist](etc/instance/c
145145
Upon a successful installation, you'll see the location and URL of the newly-installed Magento 2 application in console.
146146

147147
**Web access**:
148-
- Access storefront at `http://<instance_name>.magento` (can be found in `etc/instance/<instance_name>.yaml`)
149-
- Access admin panel at `http://<instance_name>.magento/admin/`
148+
- Access storefront at `http://magento.<instance_name>` (can be found in `etc/instance/<instance_name>.yaml`)
149+
- Access admin panel at `http://magento.<instance_name>/admin/`
150150
- Magento admin user/password: `admin/123123q`
151151
- Rabbit MQ control panel: run `bash k-open-rabbitmq`, credentials `admin`/`123123q`
152152

etc/guest/.gitignore

-1
This file was deleted.

etc/helm/templates/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/_nginx-servers.tpl

etc/helm/templates/_nginx-server.tpl.dist

-8
This file was deleted.

etc/magento2_default_varnish.vcl.dist

-169
This file was deleted.

etc/magento2_virtual_host.conf.dist

-11
This file was deleted.

init_project.sh

-4
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,6 @@ if [[ ${force_project_cleaning} -eq 1 ]]; then
7474
}
7575
fi
7676

77-
mv "${devbox_dir}/etc/guest/.gitignore" "${devbox_dir}/etc/.gitignore.back"
78-
rm -rf "${devbox_dir}/.devbox" "${devbox_dir}/etc/guest"
79-
mkdir "${devbox_dir}/etc/guest"
80-
mv "${devbox_dir}/etc/.gitignore.back" "${devbox_dir}/etc/guest/.gitignore"
8177
cd "${devbox_dir}/log" && mv email/.gitignore email_gitignore.back && rm -rf email && mkdir email && mv email_gitignore.back email/.gitignore
8278
fi
8379

k-get-context

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
cd "$(dirname "${BASH_SOURCE[0]}")" && devbox_dir=$PWD
6+
7+
source "${devbox_dir}/scripts/functions.sh"
8+
resetNestingLevel
9+
current_script_name=`basename "$0"`
10+
initLogFile ${current_script_name}
11+
12+
debug_devbox_project="$(bash "${devbox_dir}/scripts/get_env_config_value.sh" "debug_devbox_project")"
13+
if [[ ${debug_devbox_project} -eq 1 ]]; then
14+
set -x
15+
fi
16+
17+
context=$(getContext)
18+
19+
if [[ -z ${context} ]]; then
20+
echo "Context is not set. Use 'k-set-context <context-name>' to set it."
21+
exit 1
22+
fi
23+
24+
echo ${context}

scripts/functions.sh

-1
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,6 @@ function loginToPodContainer()
300300

301301
function getContext()
302302
{
303-
# TODO: Add safety checks
304303
cat "${context_file}"
305304
}
306305

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
cd "$(dirname "${BASH_SOURCE[0]}")/../.." && devbox_dir=$PWD
6+
7+
source "${devbox_dir}/scripts/functions.sh"
8+
resetNestingLevel
9+
current_script_name=`basename "$0"`
10+
initLogFile ${current_script_name}
11+
12+
debug_devbox_project="$(bash "${devbox_dir}/scripts/get_env_config_value.sh" "debug_devbox_project")"
13+
if [[ ${debug_devbox_project} -eq 1 ]]; then
14+
set -x
15+
fi
16+
17+
nginx_servers_config_file="${devbox_dir}/etc/helm/templates/_nginx-servers.tpl"
18+
19+
status "Regenerating '${nginx_servers_config_file}'"
20+
21+
rm -f "${nginx_servers_config_file}"
22+
23+
echo '{{- define "common.nginx.servers.config" -}}' >> "${nginx_servers_config_file}"
24+
echo '{{/* WARNING: Do not modify this file directly, it is auto-generated and any changes will be overwritten. */}}' >> "${nginx_servers_config_file}"
25+
26+
for instance_name in $(getInstanceList); do
27+
cat >> "${nginx_servers_config_file}" <<- LITERAL
28+
server {
29+
listen "{{ .Values.global.monolith.service.nginxPort }}";
30+
server_name $(getInstanceDomainName ${instance_name});
31+
set \$MAGE_ROOT {{.Values.global.monolith.volumeHostPath}}/${instance_name};
32+
{{- include "common.nginx.config" . | nindent 2 }}
33+
}
34+
LITERAL
35+
done
36+
echo '{{- end -}}' >> "${nginx_servers_config_file}"
37+
38+
info "$(regular)See details in $(bold)${devbox_dir}/log/${current_script_name}.log$(regular). For debug output set $(bold)debug:devbox_project$(regular) to $(bold)1$(regular) in $(bold)etc/config.yaml$(regular)"

scripts/host/init_instance.sh

-3
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,6 @@ fi
184184
cd "${devbox_dir}"
185185

186186
status "Configuring kubernetes cluster on the minikube"
187-
# TODO: Optimize. Helm tiller must be initialized and started before environment configuration can begin
188-
helm init --wait
189-
#waitForKubernetesPodToRun 'tiller-deploy'
190187

191188
# TODO: Check if environment upgrade can be safely removed
192189
bash "${devbox_dir}/scripts/host/k_upgrade_environment.sh"

scripts/host/k_install_environment.sh

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ nfs_server_ip="$(bash "${devbox_dir}/scripts/get_env_config_value.sh" "guest_nfs
1515
use_varnish="$(bash "${devbox_dir}/scripts/get_env_config_value.sh" "environment_use_varnish")"
1616
use_nfs="$(bash "${devbox_dir}/scripts/get_env_config_value.sh" "guest_use_nfs")"
1717

18+
bash "${devbox_dir}/scripts/host/configure_nginx_servers.sh"
19+
1820
status "Deploying cluster, it may take several minutes"
1921

2022
cd "${devbox_dir}/etc/helm"

scripts/host/k_upgrade_environment.sh

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ nfs_server_ip="$(bash "${devbox_dir}/scripts/get_env_config_value.sh" "guest_nfs
1515
use_varnish="$(bash "${devbox_dir}/scripts/get_env_config_value.sh" "environment_use_varnish")"
1616
use_nfs="$(bash "${devbox_dir}/scripts/get_env_config_value.sh" "guest_use_nfs")"
1717

18+
bash "${devbox_dir}/scripts/host/configure_nginx_servers.sh"
19+
1820
status "Upgrading cluster, it may take several minutes"
1921

2022
# TODO: Eliminate code duplication with k_install_environment

tests/Ce23WithSampleDataMysqlSearchNoNfsTest.sh

-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ function oneTimeSetUp
2626
function setUp()
2727
{
2828
debug_devbox_project=0
29-
skip_codebase_stash=0
3029
}
3130

3231
function tearDown()
@@ -35,7 +34,6 @@ function tearDown()
3534

3635
if [[ ${delete_test_project_on_tear_down} -eq 1 ]]; then
3736
stashLogs
38-
stashMagentoCodebase
3937
clearTestTmp
4038
fi
4139

@@ -54,7 +52,6 @@ See logs in ${logs_dir}"
5452
function testCe23WithSampleDataMysqlSearchNoNfs()
5553
{
5654
current_config_name="ce23_with_sample_data_mysql_search_no_nfs"
57-
current_codebase="ce23_with_sample_data"
5855

5956
installEnvironment
6057

tests/EeLinkingTest.sh

-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ function oneTimeSetUp
2626
function setUp()
2727
{
2828
debug_devbox_project=0
29-
skip_codebase_stash=0
3029
}
3130

3231
function tearDown()
@@ -35,7 +34,6 @@ function tearDown()
3534

3635
if [[ ${delete_test_project_on_tear_down} -eq 1 ]]; then
3736
stashLogs
38-
stashMagentoCodebase
3937
clearTestTmp
4038
fi
4139

@@ -54,7 +52,6 @@ See logs in ${logs_dir}"
5452
function testEeLinking()
5553
{
5654
current_config_name="ce_shallow_clone_no_nfs"
57-
current_codebase="ee"
5855
installEnvironment
5956
# assertVarnishDisabled
6057
executeBasicCommonAssertions

0 commit comments

Comments
 (0)