-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathentrypoint.sh
executable file
·138 lines (114 loc) · 3.68 KB
/
entrypoint.sh
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#!/bin/bash
set -e
source /etc/profile.d/rvm.sh
echo
echo "Welcome to OS:"
uname -v
cat /etc/issue
echo
echo "Setting system timezone..."
export DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true
echo "tzdata tzdata/Areas select America" > /tmp/tz.txt
if [ "$STAGING_SERVER" == "true" ]; then
echo "tzdata tzdata/Zones/America select Edmonton" >> /tmp/tz.txt
else
echo "tzdata tzdata/Zones/America select Vancouver" >> /tmp/tz.txt
fi
debconf-set-selections /tmp/tz.txt
rm /etc/timezone
rm /etc/localtime
dpkg-reconfigure --frontend noninteractive tzdata
if [ ! -e /usr/local/rvm/gems/ruby-2.7.7 ]; then
echo
echo "Create gemset..."
gpg --keyserver keys.openpgp.org --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
/usr/bin/curl -sSL https://get.rvm.io | bash -s stable
bash -lc 'rvm --default use ruby-2.7.7'
/usr/local/rvm/bin/rvm gemset create ruby-2.7.7
/usr/local/rvm/bin/rvm gemset use ruby-2.7.7@global
/usr/local/rvm/bin/rvm cleanup all
/usr/local/rvm/bin/rvm reload
fi
echo
echo "Ruby version:"
ruby -v
echo
echo "Node version:"
node --version
echo
echo "Yarn version:"
yarn --version
echo
echo "Installing bundler..."
/usr/local/rvm/bin/rvm-exec 2.7.7 gem install bundler -v 2.4.22
if [ ! -e /home/app/proposals/bin ]; then
echo
echo "Starting new rails app..."
su - app -c "cd /home/app; rails new proposals"
fi
echo
echo "Bundle install..."
su - app -c "cd /home/app/proposals; /usr/local/rvm/gems/default/bin/bundle install"
#echo
#echo "Bundle update..."
#su - app -c "cd /home/app/proposals; /usr/local/rvm/gems/default/bin/bundle update"
root_owned_files=`find /usr/local/rvm/gems -user root -print`
if [ -z "$root_owned_files" ]; then
echo
echo "Changing gems to non-root file permissions..."
chown app:app -R /usr/local/rvm/gems
fi
if [ -e /home/app/proposals/db/migrate ]; then
echo
echo "Running migrations..."
echo "this in prod migrations section"
cd /home/app/proposals
SECRET_KEY_BASE=token DB_USER=$DB_USER DB_PASS=$DB_PASS
bundle exec rake db:migrate RAILS_ENV=production
bundle exec rake db:migrate RAILS_ENV=development
bundle exec rake db:migrate RAILS_ENV=test
fi
if [ ! -e /home/app/proposals/config/webpacker.yml ]; then
echo "Installing Webpacker..."
su - app -c "cd /home/app/proposals; SECRET_KEY_BASE=token bundle exec rails webpacker:install"
echo
echo "Turbo install..."
su - app -c "cd /home/app/proposals; SECRET_KEY_BASE=token bundle exec rails turbo:install"
echo "Done!"
echo
fi
if [ ! -e /home/app/proposals/app/assets/stylesheets/actiontext.scss ]; then
echo "Setting up ActionText..."
su - app -c "cd /home/app/proposals; bin/rails action_text:install"
echo
echo "Done!"
fi
if [ "$RAILS_ENV" == "production" ]; then
echo
echo "Updating file permissions..."
chown app:app -R /home/app/proposals
fi
echo
echo "Compiling Assets..."
chmod 755 /home/app/proposals/node_modules
su - app -c "cd /home/app/proposals; yarn install"
if [ "$RAILS_ENV" == "production" ]; then
echo "this in prod rails section"
su - app -c "cd /home/app/proposals; RAILS_ENV=production SECRET_KEY_BASE=token bundle exec rake assets:precompile --trace"
su - app -c "cd /home/app/proposals; yarn"
# Update release tag
rake birs:release_tag
fi
echo
echo "Running: webpack --verbose --progress..."
su - app -c "cd /home/app/proposals; bin/webpack --verbose --progress"
echo
echo "Done compiling assets!"
if [ "$APPLICATION_HOST" == "localhost" ]; then
echo
echo "Launching webpack-dev-server..."
su - app -c "cd /home/app/proposals; RAILS_ENV=development SECRET_KEY_BASE=token bundle exec bin/webpack-dev-server &"
fi
echo
echo "Starting web server..."
bundle exec passenger start