-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdeploy_app
More file actions
executable file
·105 lines (105 loc) · 4.29 KB
/
deploy_app
File metadata and controls
executable file
·105 lines (105 loc) · 4.29 KB
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
#! /bin/bash -
while (( "$#" > 0 )) ; do
case $1 in
bare)
echo 'will perform bare install'
if [ ! -f .env ]; then
cp .env.dist .env;
fi
# echo "APP_ENV=$APP_ENV" >> .env
# echo "APP_SECRET=$(openssl rand -base64 12)" >> .env
# echo "DATABASE_URL=\"$DATABASE_CONNECTOR\"" >> .env
composer install
npm install --unsafe-perm
# bin/console cache:clear
chown -R :${APACHE_GROUP} var/cache
chmod -R g+w var/cache var/log
chown -R :${APACHE_GROUP} public
chmod -R g+w public/charts
bin/console cache:clear
;;
assets)
echo 'will copy application assets from aws'
mkdir -p /var/www/html/assets
rclone --config=/run/secrets/datastore copy $DATA_REMOTE:$BUCKET_NAME/assets /var/www/html/assets
bin/console assets:install public --symlink --relative
npm run build
chown -R $INSTANCE_USER:$APACHE_GROUP assets
if [ -f /var/www/html/src/Studies/MGWebGroup/MarketSurvey/webpack.config.js ]; then
npx encore prod --config src/Studies/MGWebGroup/MarketSurvey/webpack.config.js;
fi
;;
settings)
# echo 'will transfer application settings'
# rclone --config=/run/secrets/datastore copy $DATA_REMOTE:$BUCKET_NAME:config/services.yaml /var/www/html/config
echo 'no settings to transfer'
;;
data)
echo 'will copy application data from aws'
rclone --config=/run/secrets/datastore copy $DATA_REMOTE:$BUCKET_NAME/data/source /var/www/html/data/source
chown -R $INSTANCE_USER:$APACHE_GROUP data
;;
import-data)
echo 'will unpack price history files, import instruments and price data'
tar -C /var/www/html -xvf /var/www/html/data/source/ohlcv/price_history_files.tar
bin/console th:instruments:import -v --clear-db=true
bin/console th:price:import -v --provider=YAHOO --offset=1 --chunk-80 data/source/y_universe.csv
bin/console th:price:import -v --provider=YAHOO --offset=81 --chunk-80 data/source/y_universe.csv
bin/console th:price:import -v --provider=YAHOO --offset=161 --chunk-80 data/source/y_universe.csv
bin/console th:price:import -v --provider=YAHOO --offset=241 --chunk-80 data/source/y_universe.csv
bin/console th:price:import -v --provider=YAHOO --offset=321 --chunk-80 data/source/y_universe.csv
bin/console th:price:import -v --provider=YAHOO --offset=401 --chunk-80 data/source/y_universe.csv
bin/console th:price:import -v --provider=YAHOO --offset=481 data/source/y_universe.csv
;;
audit-data)
echo 'run audits on data'
bin/console th:price:audit -v --provider=YAHOO
;;
database)
echo 'create empty database'
bin/console doctrine:database:create
;;
migrations)
echo 'will perform migrations'
if [ "$APP_ENV" != 'prod' ]; then
bin/console doctrine:migrations:migrate --no-interaction
else
echo 'refuse to perform database migrations in prod environment'
exit 1
fi
;;
fixtures)
# loading of fixtures can only be done in test environment into a dedicated database
if [ "$APP_ENV" == 'test' ]; then
# if [ ! -f .env.test ]; then
# echo "KERNEL_CLASS='App\Kernel'" >> .env.test
# echo "DATABASE_URL=\"$DATABASE_CONNECTOR\"" >> .env.test
# fi
echo 'will clear out existing database and add fixtures'
bin/console doctrine:fixtures:load --group=Instruments --no-interaction
bin/console doctrine:fixtures:load --group=OHLCV1 --append --no-interaction
bin/console doctrine:fixtures:load --group=OHLCV2 --append --no-interaction
else
echo 'Application is not in test environment. Deployment of fixtures will not be performed'
exit 1
fi
;;
tests)
if [ "$APP_ENV" == 'test' ]; then
echo 'will run unit tests'
bin/phpunit --testsuite 'Date Iterators'
bin/phpunit --testsuite 'Exchange Calendars'
bin/phpunit --testsuite 'Price History'
bin/phpunit --testsuite 'Scanner'
bin/phpunit --testsuite 'Charts'
bin/phpunit --testsuite 'Commands'
else
echo 'Application is not in test or dev environment. Testing will not be performed'
exit 1
fi
;;
*) echo "invalid directive $1"
;;
esac
shift
done