-
Notifications
You must be signed in to change notification settings - Fork 2
/
docker-setup
123 lines (113 loc) · 3.49 KB
/
docker-setup
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#!/bin/bash -xe
main() {
local magento_version="${1:- 1.9.1.0}"
if [[ $1 = bash ]]; then
shift
exec bash "$@"
fi
makedirs
fetch_unpack_magento "$magento_version"
install_magento
copy_testkit
validate
}
makedirs() {
mkdir -p build/magetars build/magento build/doc build/pdepend build/phpmd build/phpunit
}
fetch_unpack_magento() (
local magento_version="${1:- 1.9.1.0}"
local magento_urls=(
"http://10.9.67.238/pkgs/magento-${magento_version}.tar.xz"
"http://www.magentocommerce.com/downloads/assets/${magento_version}/magento-${magento_version}.tar.bz2"
)
local magento_tarballs=("${magento_urls[@]##*/}")
local url
local file
local file_found=0
cd build/magetars
for file in "${magento_tarballs[@]}"; do
if [[ -f "$file" ]]; then
file_found=1
break
fi
done
if (( ! file_found )); then
for url in "${magento_urls[@]}"; do
# Magento site doesn't support resuming downloads.
if curl -f -#O "$url"; then
file="${url##*/}"
break
fi
done
fi
cd ../magento
[[ -f app/etc/local.xml ]] || tar --strip-components=1 -xf "../magetars/${file}"
)
mysql() {
command mysql -h db_1 \
-u "$DB_1_ENV_MYSQL_USER" \
--password="$DB_1_ENV_MYSQL_PASSWORD" \
"$DB_1_ENV_MYSQL_DATABASE" \
"$@"
}
is_db_up() {
local -i counter="$1"
while (( counter-- > 0 )); do
mysql -e 'SELECT 1\g' &> /dev/null && return
sleep 1
done
return 1
}
install_magento() (
local db_timeout=12 # Seconds to wait for db to come up
cd build/magento
is_db_up "$db_timeout"
if [[ ! -f app/etc/local.xml ]]; then
php install.php \
--admin_email admin@example.com \
--admin_firstname ad \
--admin_lastname min \
--admin_password testing123 \
--admin_username admin \
--db_host db_1 \
--db_name "$DB_1_ENV_MYSQL_DATABASE" \
--db_pass "$DB_1_ENV_MYSQL_PASSWORD" \
--db_user "$DB_1_ENV_MYSQL_USER" \
--default_currency USD \
--license_agreement_accepted yes \
--locale en_US \
--secure_base_url "http://${MAGENTO_HOST-example.com}/" \
--skip_url_validation yes \
--timezone America/New_York \
--url "http://${MAGENTO_HOST-example.com}/" \
--use_rewrites yes \
--use_secure no \
--use_secure_admin no
fi
chown -R :www-data media var
chmod -R g+sw media var
if [[ ! $MAGENTO_HOST ]]; then
# No base url was specified, so disable redirecting to base url.
mysql -e 'DELETE FROM core_config_data WHERE path LIKE "web/%secure/base_url"\g'
magerun cache:disable config
magerun dev:log --on --global .
magerun dev:symlinks --on --global .
magerun index:reindex:all .
fi
if cd errors && [[ ! -f local.xml.sample ]]; then
ln -s local.xml.sample local.xml
fi
)
magerun() {
n98-magerun --skip-root-check "$@"
}
copy_testkit() {
cp tests/composer.xml build/magento/app/etc/
cp tests/local.xml.phpunit.docker build/magento/app/etc/local.xml.phpunit
cp tests/phpunit.xml.dist build/magento/
cp tests/composer.docker.json build/magento/composer.json
}
validate() (
cd build/magento && magerun sys:check .
)
main "$@"