-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.platform.app.yaml
105 lines (88 loc) · 3.53 KB
/
.platform.app.yaml
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
name: 'yclassapps'
type: "ruby:3.0"
dependencies:
nodejs:
yarn: "*"
# The relationships of the application with services or other applications.
#
# The left-hand side is the name of the relationship as it will be exposed
# to the application in the PLATFORM_RELATIONSHIPS variable. The right-hand
# side is in the form '<service name>:<endpoint name>'.
relationships:
postgresdatabase: 'dbpostgres:postgresql'
# The size of the persistent disk of the application (in MB).
disk: 2048
# Set environment variables to adjust how Rails will run.
variables:
env:
BUNDLE_CACHE_ALL: '1'
BUNDLE_CLEAN: '1'
BUNDLE_DEPLOYMENT: '1'
BUNDLE_ERROR_ON_STDERR: '1'
BUNDLE_WITHOUT: 'development:test'
DEFAULT_BUNDLER_VERSION: "2.4.13" # in case none is mentioned in Gemfile.lock
EXECJS_RUNTIME: 'Node'
NODE_ENV: 'production'
NODE_VERSION: v14.17.6
NVM_VERSION: v0.38.0
RACK_ENV: 'production'
RAILS_ENV: 'production'
RAILS_LOG_TO_STDOUT: '1'
RAILS_TMP: '/tmp'
hooks:
build: |
set -e
echo "Installing NVM $NVM_VERSION"
unset NPM_CONFIG_PREFIX
export NVM_DIR="$PLATFORM_APP_DIR/.nvm"
# install.sh will automatically install NodeJS based on the presence of $NODE_VERSION
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/$NVM_VERSION/install.sh | bash
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
# we install the bundled bundler version and fallback to a default (in env vars above)
export BUNDLER_VERSION="$(grep -A 1 "BUNDLED WITH" Gemfile.lock | tail -n 1)" || $DEFAULT_BUNDLER_VERSION
echo "Install bundler $BUNDLER_VERSION"
gem install --no-document bundler -v $BUNDLER_VERSION
echo "Installing gems"
# We copy the bundle directory to the Platform.sh cache directory for
# safe keeping, then restore from there on the next build. That allows
# bundler to skip downloading code it doesn't need to.
[ -d "$PLATFORM_CACHE_DIR/bundle" ] && \
rsync -az --delete "$PLATFORM_CACHE_DIR/bundle/" vendor/bundle/
mkdir -p "$PLATFORM_CACHE_DIR/bundle"
bundle install
# synchronize updated cache for next build
rsync -az --delete vendor/bundle/ "$PLATFORM_CACHE_DIR/bundle/"
# precompile assets
echo "Precompiling assets"
# We copy the webpacker directory to the Platform.sh cache directory for
# safe keeping, then restore from there on the next build. That allows
# bundler to skip downloading code it doesn't need to.
mkdir -p "$PLATFORM_CACHE_DIR/webpacker"
mkdir -p "$RAILS_TMP/cache/webpacker"
[ -d "$PLATFORM_CACHE_DIR/webpacker" ] && \
rsync -az --delete "$PLATFORM_CACHE_DIR/webpacker/" $RAILS_TMP/cache/webpacker/
# We dont need secret here https://github.com/rails/rails/issues/32947
SECRET_KEY_BASE=1 bundle exec rails assets:precompile
rsync -az --delete $RAILS_TMP/cache/webpacker/ "$PLATFORM_CACHE_DIR/webpacker/"
deploy: bundle exec rake db:migrate
mounts:
"/log":
source: local
source_path: log
"/storage":
source: local
source_path: storage
"/tmp":
source: local
source_path: tmp
web:
upstream:
socket_family: unix
commands:
start: "bundle exec unicorn -l $SOCKET"
locations:
"/":
root: "public"
passthru: true
expires: 1h
allow: true