Skip to content

Commit a8d9536

Browse files
authored
Merge pull request #13 from magento/develop
Develop
2 parents 76535e1 + 5564b41 commit a8d9536

15 files changed

+328
-33
lines changed

Diff for: README.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -303,8 +303,13 @@ Sometimes it is necessary to test upgrade flow. This can be easily done as follo
303303
- Use commands described in [Switch between CE and EE](#switch-between-ce-and-ee) section with `-u` flag
304304

305305
### Multiple Magento instances
306+
Edit etc/config.yaml.
307+
Change ce branch and add checkout repository and branch.
308+
Follow [Installation steps](#installation-steps), when running init-magento use -e argument
306309

307-
Not available yet.
310+
```bash
311+
helm init-magento -e
312+
```
308313
<!--To install several Magento instances based on different code bases, just follow [Installation steps](#installation-steps) to initialize project in another directory on the host.
309314
Unique IP address, SSH port and domain name will be generated for each new instance if not specified manually in `etc/config.yaml`
310315
-->

Diff for: etc/config.yaml.dist

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ repository_url:
1616
# [To apply changes: init_project.sh -fc]
1717
# [email protected]:magento/magento2ce.git OR custom one. Use '::' to specify a specific branch, e.g: [email protected]:magento/magento2.git::2.1
1818
ce: "[email protected]:magento/magento2.git"
19+
checkout: "[email protected]:magento/magento2.git"
1920
# [email protected]:magento/magento2ee.git OR custom one
2021
ee: ""
2122
# can be replaced with custom repository. Use '::' to specify a specific branch, e.g: [email protected]:magento/magento2-sample-data.git::2.1-develop

Diff for: etc/helm/charts/checkout/templates/checkout-deployment.yaml

+14-1
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,23 @@ spec:
2121
spec:
2222
containers:
2323
- name: {{ .Chart.Name }}
24-
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
24+
image: magento2-monolith:dev
2525
imagePullPolicy: {{ .Values.image.pullPolicy }}
2626
ports:
2727
- containerPort: 80
28+
env:
29+
- name: VAGRANT_ROOT
30+
value: {{.Values.global.checkout.volumeHostPath}}
31+
- name: COMPOSER_HOME
32+
value: {{.Values.global.checkout.volumeHostPath}}/.composer
33+
- name: MAGENTO_ROOT
34+
value: {{.Values.global.checkout.volumeHostPath}}/checkout
35+
- name: MAGENTO_ROOT_HOST
36+
value: {{.Values.global.checkout.volumeHostPath}}/checkout
37+
- name: VAGRANT_ROOT_HOST
38+
value: {{.Values.global.checkout.volumeHostPath}}
39+
- name: IS_WINDOWS_HOST
40+
value: "0"
2841
volumeMounts:
2942
- name: {{ .Chart.Name }}-code
3043
mountPath: {{.Values.global.checkout.volumeHostPath}}

Diff for: etc/helm/charts/checkout/templates/configmap.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ data:
3333
3434
server {
3535
listen 8001;
36+
listen 30102;
37+
listen 80;
3638
3739
server_name _;
3840
set $MAGE_ROOT {{.Values.global.checkout.volumeHostPath}}/checkout;

Diff for: etc/helm/charts/checkout/values.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ checkout:
2525
port: 80
2626
deployment:
2727
nginxImage: nginx:1.9
28-
codeImage: shiftedreality/magento-kubernetes-components-php
29-
imageTag: 7.1-fpm
28+
codeImage: magento2-monolith
29+
imageTag: dev
3030
imagePullPolicy: Always
3131

3232
resources: {}

Diff for: etc/helm/templates/configmap.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ data:
3232
3333
server {
3434
listen 8001;
35+
listen 30301;
3536
3637
server_name _;
3738
set $MAGE_ROOT {{.Values.global.monolith.volumeHostPath}}/magento;

Diff for: init_project.sh

+21-3
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,22 @@ if [[ ! -f "${config_path}" ]]; then
2222
fi
2323

2424
magento_ce_dir="${vagrant_dir}/magento"
25+
magento_checkout_dir="${vagrant_dir}/checkout"
2526
magento_ce_sample_data_dir="${magento_ce_dir}/magento2ce-sample-data"
2627
magento_ee_dir="${magento_ce_dir}/magento2ee"
2728
magento_ee_sample_data_dir="${magento_ce_dir}/magento2ee-sample-data"
2829
host_os="$(bash "${vagrant_dir}/scripts/host/get_host_os.sh")"
2930
use_nfs="$(bash "${vagrant_dir}/scripts/get_config_value.sh" "guest_use_nfs")"
3031
repository_url_ce="$(bash "${vagrant_dir}/scripts/get_config_value.sh" "repository_url_ce")"
31-
#repository_url_checkout="$(bash "${vagrant_dir}/scripts/get_config_value.sh" "repository_url_checkout")"
32+
repository_url_checkout="$(bash "${vagrant_dir}/scripts/get_config_value.sh" "repository_url_checkout")"
3233
repository_url_ee="$(bash "${vagrant_dir}/scripts/get_config_value.sh" "repository_url_ee")"
3334
composer_project_name="$(bash "${vagrant_dir}/scripts/get_config_value.sh" "composer_project_name")"
3435
composer_project_url="$(bash "${vagrant_dir}/scripts/get_config_value.sh" "composer_project_url")"
3536
checkout_source_from="$(bash "${vagrant_dir}/scripts/get_config_value.sh" "checkout_source_from")"
3637

3738
function checkoutSourceCodeFromGit()
3839
{
40+
local checkout_enabled=${1}
3941
if [[ ! -d ${magento_ce_dir} ]]; then
4042
if [[ ${host_os} == "Windows" ]]; then
4143
status "Configuring git for Windows host"
@@ -45,6 +47,9 @@ function checkoutSourceCodeFromGit()
4547
fi
4648

4749
initMagentoCeGit
50+
if [[ ${checkout_enabled} -eq 1 ]]; then
51+
initMagentoCheckoutGit
52+
fi
4853
initMagentoCeSampleGit
4954

5055
# By default EE repository is not specified and EE project is not checked out
@@ -64,6 +69,11 @@ function initMagentoCeGit()
6469
initGitRepository ${repository_url_ce} "CE" "${magento_ce_dir}"
6570
}
6671

72+
function initMagentoCheckoutGit()
73+
{
74+
initGitRepository ${repository_url_checkout} "checkout" "${magento_checkout_dir}"
75+
}
76+
6777
function initMagentoEeGit()
6878
{
6979
initGitRepository ${repository_url_ee} "EE" "${magento_ee_dir}"
@@ -208,7 +218,7 @@ if [[ ! -d ${magento_ce_dir} ]]; then
208218
if [[ "${checkout_source_from}" == "composer" ]]; then
209219
composerCreateProject
210220
elif [[ "${checkout_source_from}" == "git" ]]; then
211-
checkoutSourceCodeFromGit
221+
checkoutSourceCodeFromGit ${enable_checkout}
212222
else
213223
error "Value specified for 'checkout_source_from' is invalid. Supported options: composer OR git"
214224
exit 1
@@ -265,7 +275,12 @@ fi
265275
minikube_ip="$(minikube service magento2-monolith --url | grep -oE '[0-9][^:]+' | head -1)"
266276
status "Saving minikube IP to etc/config.yaml (${minikube_ip})"
267277
sed -i.back "s|ip_address: \".*\"|ip_address: \"${minikube_ip}\"|g" "${config_path}"
268-
sed -i.back "s|host_name: \".*\"|host_name: \"${minikube_ip}\"|g" "${config_path}"
278+
if [[ "${enable_checkout}" == 1 ]]; then
279+
sed -i.back "s|host_name: \".*\"|host_name: \"${minikube_ip}\"|g" "${config_path}"
280+
else
281+
sed -i.back "s|host_name: \".*\"|host_name: \"${minikube_ip}\"|g" "${config_path}"
282+
fi
283+
269284
rm -f "${config_path}.back"
270285

271286
bash "${vagrant_dir}/scripts/host/check_mounted_directories.sh"
@@ -289,6 +304,9 @@ else
289304
else
290305
bash "${vagrant_dir}/scripts/host/m_switch_to_ce.sh" -f 2> >(logError)
291306
fi
307+
if [[ "${enable_checkout}" == 1 ]]; then
308+
bash "${vagrant_dir}/scripts/host/m_switch_to_ce.sh" -p=checkout -f 2> >(logError)
309+
fi
292310
fi
293311

294312
success "Project initialization succesfully completed (make sure there are no errors in the log above)"

Diff for: scripts/guest/composer_checkout.sh

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env bash
2+
3+
# This script allows to use credentials specified in etc/composer/auth.json without declaring them globally
4+
5+
cd "$(dirname "${BASH_SOURCE[0]}")/../.." && vagrant_dir=$PWD
6+
7+
source "${vagrant_dir}/scripts/functions.sh"
8+
9+
status "Executing composer command"
10+
incrementNestingLevel
11+
12+
composer_auth_json="${vagrant_dir}/etc/composer/auth.json"
13+
14+
# commented out due to composer conflicts
15+
# ${php_executable} "${composer_phar}" global require "hirak/prestissimo:^0.3"
16+
17+
cd "${VAGRANT_ROOT}/checkout"
18+
if [[ -f ${composer_auth_json} ]]; then
19+
status "Exporting etc/auth.json to environment variable"
20+
export COMPOSER_AUTH="$(cat "${composer_auth_json}")"
21+
fi
22+
23+
status "composer --no-interaction "$@""
24+
composer --no-interaction "$@" 2> >(log) > >(log)
25+
26+
decrementNestingLevel

Diff for: scripts/guest/m-checkout-postinstall

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env bash
2+
3+
vagrant_dir="${VAGRANT_ROOT}"
4+
5+
source "${vagrant_dir}/scripts/functions.sh"
6+
7+
magento_host_name="$(bash ${get_config_value} "magento_host_name")"
8+
magento_host_name="http://${magento_host_name}:30102/"
9+
php "${MAGENTO_ROOT}/bin/magento" module:disable Magento_CustomerProxy Magento_CatalogProxy 2> >(logError)
10+
php "${MAGENTO_ROOT}/bin/magento" config:set service/host/address "${magento_host_name}" 2> >(logError)

Diff for: scripts/guest/m-checkout-reinstall

+139
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
#!/usr/bin/env bash
2+
3+
vagrant_dir="${VAGRANT_ROOT}"
4+
5+
source "${vagrant_dir}/scripts/functions.sh"
6+
7+
PORT=30102
8+
get_config_value="${vagrant_dir}/scripts/get_config_value.sh"
9+
magento_host_name="$(bash ${get_config_value} "magento_host_name")"
10+
magento_host_name="${magento_host_name}:30102"
11+
magento_db_name="checkout"
12+
13+
status ${magento_host_name}
14+
use_nfs="$(bash "${vagrant_dir}/scripts/get_config_value.sh" "guest_use_nfs")"
15+
is_windows_host=${IS_WINDOWS_HOST}
16+
generate_basic_data="$(bash ${get_config_value} "magento_generate_basic_data")"
17+
18+
declare -A setupOptions
19+
setupOptions[admin_frontname]="$(bash ${get_config_value} "magento_admin_frontname")"
20+
setupOptions[language]="$(bash ${get_config_value} "magento_language")"
21+
setupOptions[timezone]="$(bash ${get_config_value} "magento_timezone")"
22+
setupOptions[currency]="$(bash ${get_config_value} "magento_currency")"
23+
setupOptions[admin_user]="$(bash ${get_config_value} "magento_admin_user")"
24+
setupOptions[admin_password]="$(bash ${get_config_value} "magento_admin_password")"
25+
setupOptions[db_host]='magento2-mysql'
26+
setupOptions[db_name]="${magento_db_name}"
27+
setupOptions[db_user]='root'
28+
setupOptions[db_password]='123123q'
29+
setupOptions[base_url]="http://${magento_host_name}/"
30+
setupOptions[admin_lastname]='Admin'
31+
setupOptions[admin_firstname]='Admin'
32+
setupOptions[admin_email]='[email protected]'
33+
setupOptions[amqp_host]='magento2-rabbitmq'
34+
setupOptions[amqp_port]='5672'
35+
setupOptions[amqp_user]='admin'
36+
setupOptions[amqp_password]='123123q'
37+
setupOptions[amqp_virtualhost]='/'
38+
39+
#if [[ ${is_windows_host} == 1 ]] || [[ ${use_nfs} == 0 ]]; then
40+
# sudo chown -R vagrant:vagrant ${MAGENTO_ROOT}
41+
#fi
42+
#
43+
#status "Killing MQ processes"
44+
#pkill -f queue
45+
46+
status "Installing/re-installing Magento"
47+
incrementNestingLevel
48+
49+
cd ${MAGENTO_ROOT}
50+
51+
status "Removing Magento configuration files (env.php and config.php)"
52+
rm -f "${MAGENTO_ROOT}/app/etc/config.php"
53+
rm -f "${MAGENTO_ROOT}/app/etc/env.php"
54+
55+
status "Restoring stored in git config.php (if applicable)"
56+
git checkout "${MAGENTO_ROOT}/app/etc/config.php" &>/dev/null
57+
58+
bash "${VAGRANT_ROOT}/scripts/guest/m-clear-cache"
59+
# Cache cleaning takes 5-10 seconds and should be avoided until the end of installation to speed up the process
60+
export SKIP_CACHE_CLEAN=1
61+
62+
db_names=("${setupOptions[db_name]}" "magento_integration_tests" )
63+
for db_name in "${db_names[@]}"; do
64+
status "Dropping and creating '${db_name}' DB"
65+
mysql -u"${setupOptions[db_user]}" -p"${setupOptions[db_password]}" -h"${setupOptions[db_host]}" -e"drop database if exists ${db_name}; create database ${db_name};"
66+
done
67+
68+
# Install Magento application
69+
cd ${MAGENTO_ROOT}
70+
71+
install_cmd="./bin/magento setup:install \
72+
--db-host=${setupOptions[db_host]} \
73+
--db-name=${setupOptions[db_name]} \
74+
--db-user=${setupOptions[db_user]} \
75+
--db-password=${setupOptions[db_password]} \
76+
--backend-frontname=${setupOptions[admin_frontname]} \
77+
--base-url=${setupOptions[base_url]} \
78+
--language=${setupOptions[language]} \
79+
--timezone=${setupOptions[timezone]} \
80+
--currency=${setupOptions[currency]} \
81+
--admin-lastname=${setupOptions[admin_lastname]} \
82+
--admin-firstname=${setupOptions[admin_firstname]} \
83+
--admin-email=${setupOptions[admin_email]} \
84+
--admin-user=${setupOptions[admin_user]} \
85+
--admin-password=${setupOptions[admin_password]} \
86+
--cleanup-database \
87+
--use-rewrites=1"
88+
89+
# Configure Rabbit MQ
90+
#if [[ -d "${MAGENTO_ROOT}/app/code/Magento/MessageQueue" ]] || [[ -d "${MAGENTO_ROOT}/vendor/magento/module-message-queue" ]]; then
91+
# install_cmd="${install_cmd} \
92+
# --amqp-host=${setupOptions[amqp_host]} \
93+
# --amqp-port=${setupOptions[amqp_port]} \
94+
# --amqp-user=${setupOptions[amqp_user]} \
95+
# --amqp-virtualhost=${setupOptions[amqp_virtualhost]} \
96+
# --amqp-ssl=false \
97+
# --amqp-ssl-options=[] \
98+
# --amqp-password=${setupOptions[amqp_password]}"
99+
#fi
100+
101+
# TODO: Permission denied
102+
#sudo chmod +x bin/magento
103+
status "${install_cmd}"
104+
php ${install_cmd} 2> >(logError) > >(log)
105+
php "${MAGENTO_ROOT}/bin/magento" module:disable Magento_CheckoutProxy Magento_SalesProxy Magento_QuoteProxy 2> >(logError) > >(log)
106+
monolith_host_name="http://$(bash ${get_config_value}/ "magento_host_name")/"
107+
php "${MAGENTO_ROOT}/bin/magento" config:set service/host/address "${monolith_host_name}" 2> >(logError) > >(log)
108+
109+
# Comment out the line above and uncomment the one below to debug Magento Setup script
110+
# php -d xdebug.remote_autostart=1 ${install_cmd} 2> >(logError) > >(log)
111+
112+
#status "Configuring Redis as cache backend"
113+
#php "${MAGENTO_ROOT}/bin/magento" setup:config:set --page-cache=redis --page-cache-redis-server=magento2-redis-master
114+
#php "${MAGENTO_ROOT}/bin/magento" setup:config:set --cache-backend=redis --cache-backend-redis-server=magento2-redis-master
115+
116+
if [[ $? != 0 ]]; then
117+
error "Magento installation failed."
118+
exit 1
119+
fi
120+
121+
# TODO: Confibure varnish
122+
#bash "${vagrant_dir}/scripts/guest/configure_varnish" -f
123+
124+
# TODO: Remove
125+
#if [[ ${is_windows_host} == 1 ]] || [[ ${use_nfs} == 0 ]]; then
126+
# status "Changing ownership of "${MAGENTO_ROOT}" to vagrant:vagrant"
127+
# sudo chown -R vagrant:vagrant ${MAGENTO_ROOT}
128+
#fi
129+
130+
#bash "${VAGRANT_ROOT}/scripts/guest/configure_search_engine"
131+
#bash "${VAGRANT_ROOT}/scripts/guest/change_magento_config_for_functional_tests"
132+
#bash "${VAGRANT_ROOT}/scripts/guest/update_magento_config" 'admin/security/session_lifetime' '86400'
133+
134+
export SKIP_CACHE_CLEAN=0
135+
bash "${VAGRANT_ROOT}/scripts/guest/m-clear-cache"
136+
137+
if [[ ${generate_basic_data} != 0 ]]; then
138+
bash "${VAGRANT_ROOT}/scripts/guest/generate_basic_data"
139+
fi

Diff for: scripts/guest/m-reinstall

+21-1
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,28 @@ vagrant_dir="${VAGRANT_ROOT}"
44

55
source "${vagrant_dir}/scripts/functions.sh"
66

7+
PORT=80
8+
for i in "$@"
9+
do
10+
case $i in
11+
-p=*|--path=*)
12+
PORT="${i#*=}"
13+
shift # past argument=value
14+
;;
15+
*)
16+
# unknown option
17+
;;
18+
esac
19+
done
720
get_config_value="${vagrant_dir}/scripts/get_config_value.sh"
821
magento_host_name="$(bash ${get_config_value} "magento_host_name")"
22+
magento_db_name="magento"
23+
if [[ ${PORT} != 80 ]]; then
24+
magento_host_name="${magento_host_name}:${PORT}"
25+
magento_db_name="checkout"
26+
fi
27+
28+
status ${magento_host_name}
929
use_nfs="$(bash "${vagrant_dir}/scripts/get_config_value.sh" "guest_use_nfs")"
1030
is_windows_host=${IS_WINDOWS_HOST}
1131
generate_basic_data="$(bash ${get_config_value} "magento_generate_basic_data")"
@@ -18,7 +38,7 @@ setupOptions[currency]="$(bash ${get_config_value} "magento_currency")"
1838
setupOptions[admin_user]="$(bash ${get_config_value} "magento_admin_user")"
1939
setupOptions[admin_password]="$(bash ${get_config_value} "magento_admin_password")"
2040
setupOptions[db_host]='magento2-mysql'
21-
setupOptions[db_name]='magento'
41+
setupOptions[db_name]="${magento_db_name}"
2242
setupOptions[db_user]='root'
2343
setupOptions[db_password]='123123q'
2444
setupOptions[base_url]="http://${magento_host_name}/"

Diff for: scripts/host/m_checkout_composer.sh

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env bash
2+
3+
cd "$(dirname "${BASH_SOURCE[0]}")/../.." && vagrant_dir=$PWD
4+
5+
source "${vagrant_dir}/scripts/functions.sh"
6+
7+
cd "${vagrant_dir}"
8+
9+
# TODO: parameterize container
10+
11+
arguments=$@
12+
executeInMagento2CheckoutContainer -- "${vagrant_dir}/scripts/guest/composer_checkout.sh" ${arguments} 2> >(logError)

0 commit comments

Comments
 (0)