-
Notifications
You must be signed in to change notification settings - Fork 157
/
Copy pathassemble
executable file
·71 lines (56 loc) · 2.1 KB
/
assemble
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
#!/bin/bash
function rake_assets_precompile() {
[[ "$DISABLE_ASSET_COMPILATION" == "true" ]] && return
[ ! -f Gemfile ] && return
[ ! -f Rakefile ] && return
! grep " rake " Gemfile.lock >/dev/null && return
! bundle exec 'rake -T' | grep "assets:precompile" >/dev/null && return
echo "---> Starting asset compilation ..."
bundle exec rake assets:precompile
}
set -e
export RACK_ENV=${RACK_ENV:-"production"}
if [ -n "$RUBYGEM_MIRROR" ]; then
bundle config mirror.https://rubygems.org $RUBYGEM_MIRROR
fi
shopt -s dotglob
echo "---> Installing application source ..."
mv /tmp/src/* ./
echo "---> Building your Ruby application from source ..."
if [ -f Gemfile ]; then
ADDTL_BUNDLE_ARGS="--retry 2"
if [ -f Gemfile.lock ]; then
ADDTL_BUNDLE_ARGS+=" --deployment"
fi
if [[ "$RAILS_ENV" == "development" || "$RACK_ENV" == "development" ]]; then
BUNDLE_WITHOUT=${BUNDLE_WITHOUT:-"test"}
elif [[ "$RAILS_ENV" == "test" || "$RACK_ENV" == "test" ]]; then
BUNDLE_WITHOUT=${BUNDLE_WITHOUT:-"development"}
else
BUNDLE_WITHOUT=${BUNDLE_WITHOUT:-"development:test"}
fi
if [ -n "$BUNDLE_WITHOUT" ]; then
ADDTL_BUNDLE_ARGS+=" --without $BUNDLE_WITHOUT"
fi
echo "---> Running 'bundle install ${ADDTL_BUNDLE_ARGS}' ..."
bundle install --path ./bundle ${ADDTL_BUNDLE_ARGS}
echo "---> Cleaning up unused ruby gems ..."
bundle clean -V
fi
if ! bundle exec rackup -h &>/dev/null; then
echo "WARNING: Rubygem Rack is not installed in the present image."
echo " Add rack to your Gemfile in order to start the web server."
fi
if [[ "$RAILS_ENV" == "production" || "$RACK_ENV" == "production" ]]; then
rake_assets_precompile
fi
# Fix source directory permissions
fix-permissions ./
# Make the ./tmp folder world writeable as Rails or other frameworks might use
# it to store temporary data (uploads/cache/sessions/etcd).
# The ./db folder has to be writeable as well because when Rails complete the
# migration it writes the schema version into ./db/schema.db
set +e
[[ -d ./tmp ]] && chgrp -R 0 ./tmp && chmod -R g+rw ./tmp
[[ -d ./db ]] && chgrp -R 0 ./db && chmod -R g+rw ./db
set -e