Skip to content

Commit 1e57fa5

Browse files
authored
Assemble file has been created
1 parent 022d87e commit 1e57fa5

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed

.s2i/bin/assemble

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#!/bin/bash
2+
3+
function rake_assets_precompile() {
4+
[[ "$DISABLE_ASSET_COMPILATION" == "true" ]] && return
5+
[ ! -f Gemfile ] && return
6+
[ ! -f Rakefile ] && return
7+
! grep " rails " Gemfile.lock >/dev/null && return
8+
! grep " execjs " Gemfile.lock >/dev/null && return
9+
! bundle exec 'rake -T' | grep "assets:precompile" >/dev/null && return
10+
11+
echo "---> Starting asset compilation ..."
12+
bundle exec rake assets:precompile
13+
}
14+
15+
set -e
16+
17+
export RACK_ENV=${RACK_ENV:-"production"}
18+
19+
echo "---> Installing application source ..."
20+
cp -Rf /tmp/src/. ./
21+
22+
echo "---> Building your Ruby application from source ..."
23+
if [ -f Gemfile ]; then
24+
ADDTL_BUNDLE_ARGS=""
25+
if [ -f Gemfile.lock ]; then
26+
ADDTL_BUNDLE_ARGS="--deployment"
27+
fi
28+
29+
if [[ "$RAILS_ENV" == "development" || "$RACK_ENV" == "development" ]]; then
30+
BUNDLE_WITHOUT=${BUNDLE_WITHOUT:-"test"}
31+
elif [[ "$RAILS_ENV" == "test" || "$RACK_ENV" == "test" ]]; then
32+
BUNDLE_WITHOUT=${BUNDLE_WITHOUT:-"development"}
33+
else
34+
BUNDLE_WITHOUT=${BUNDLE_WITHOUT:-"development:test"}
35+
fi
36+
37+
echo "---> Running 'bundle install ${ADDTL_BUNDLE_ARGS}' ..."
38+
bundle install --path ./bundle ${ADDTL_BUNDLE_ARGS}
39+
40+
echo "---> Cleaning up unused ruby gems ..."
41+
bundle clean -V
42+
fi
43+
44+
if ! bundle exec rackup -h &>/dev/null; then
45+
echo "WARNING: Rubygem Rack is not installed in the present image."
46+
echo " Add rack to your Gemfile in order to start the web server."
47+
fi
48+
49+
if [[ "$RAILS_ENV" == "production" || "$RACK_ENV" == "production" ]]; then
50+
rake_assets_precompile
51+
fi
52+
53+
# Fix source directory permissions
54+
fix-permissions ./
55+
56+
# Make the ./tmp folder world writeable as Rails or other frameworks might use
57+
# it to store temporary data (uploads/cache/sessions/etcd).
58+
# The ./db folder has to be writeable as well because when Rails complete the
59+
# migration it writes the schema version into ./db/schema.db
60+
set +e
61+
[[ -d ./tmp ]] && chgrp -R 0 ./tmp && chmod -R g+rw ./tmp
62+
[[ -d ./db ]] && chgrp -R 0 ./db && chmod -R g+rw ./db
63+
set -e
64+
65+
echo "---> CUSTOM S2I ASSEMBLE COMPLETE"

0 commit comments

Comments
 (0)