Commit bc7f70ab authored by pierre.tremouilhac's avatar pierre.tremouilhac
Browse files

Merge branch 'install_script' into 'development'

installation script for setting a production server:

See merge request ComPlat/chemotion_ELN!1047
parents a61e58c0 369fc79c
......@@ -9,8 +9,8 @@ require 'capistrano/rvm' # Ruby version manager
require 'capistrano/nvm' # Node version manager
require 'capistrano/npm' # Node package manager
require 'capistrano/bundler'
require 'capistrano/rails/assets'
require 'capistrano/rails/migrations'
require 'capistrano/rails/assets'
#require 'capistrano/delayed_job'
require 'whenever/capistrano'
require 'slackistrano/capistrano'
......
......@@ -105,7 +105,7 @@ gem 'faraday_middleware', '~> 0.12.1'
gem 'httparty'
gem 'ketcherails', '~> 0.1.6', git: 'https://github.com/ComPlat/ketcher-rails',
ref: '0ad1dec8c8c91074873c93f2a73b57442ab03c6f'
ref: '34228105183085659319b67f6adb510f1afba13d'
# gem 'ketcherails', path: '../ketcher-rails'
# Free font icons
......
......@@ -6,8 +6,8 @@ GIT
GIT
remote: https://github.com/ComPlat/ketcher-rails
revision: 0ad1dec8c8c91074873c93f2a73b57442ab03c6f
ref: 0ad1dec8c8c91074873c93f2a73b57442ab03c6f
revision: 34228105183085659319b67f6adb510f1afba13d
ref: 34228105183085659319b67f6adb510f1afba13d
specs:
ketcherails (0.1.6)
active_model_serializers (< 0.10.0)
......@@ -142,7 +142,7 @@ GEM
api-pagination (4.8.2)
arel (6.0.4)
ast (2.4.0)
autoprefixer-rails (9.5.1.1)
autoprefixer-rails (9.6.4)
execjs
awesome_print (1.8.0)
axiom-types (0.1.1)
......@@ -237,10 +237,10 @@ GEM
debug_inspector (0.0.3)
delayed_cron_job (0.7.2)
delayed_job (>= 4.1)
delayed_job (4.1.7)
activesupport (>= 3.0, < 5.3)
delayed_job_active_record (4.1.3)
activerecord (>= 3.0, < 5.3)
delayed_job (4.1.8)
activesupport (>= 3.0, < 6.1)
delayed_job_active_record (4.1.4)
activerecord (>= 3.0, < 6.1)
delayed_job (>= 3.0, < 5)
descendants_tracker (0.0.4)
thread_safe (~> 0.3, >= 0.3.1)
......@@ -291,7 +291,7 @@ GEM
rubocop-rspec (~> 1.19)
globalid (0.4.2)
activesupport (>= 4.2.0)
grape (1.2.3)
grape (1.2.4)
activesupport
builder
mustermann-grape (~> 1.0.0)
......@@ -326,7 +326,7 @@ GEM
nokogiri (>= 1.6.0)
ruby_parser (~> 3.5)
htmlentities (4.3.4)
httparty (0.17.0)
httparty (0.17.1)
mime-types (~> 3.0)
multi_xml (>= 0.5.2)
i18n (0.9.5)
......@@ -337,7 +337,7 @@ GEM
jbuilder (2.8.0)
activesupport (>= 4.2.0)
multi_json (>= 1.2)
jquery-rails (4.3.3)
jquery-rails (4.3.5)
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
......@@ -367,7 +367,7 @@ GEM
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
ruby_dep (~> 1.2)
loofah (2.2.3)
loofah (2.3.0)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.7.1)
......@@ -386,13 +386,13 @@ GEM
callsite (~> 0.0, >= 0.0.11)
rack-contrib (>= 1.1, < 3)
railties (>= 3.0.0, < 7)
mime-types (3.2.2)
mime-types (3.3)
mime-types-data (~> 3.2015)
mime-types-data (3.2019.0331)
mime-types-data (3.2019.0904)
mimemagic (0.3.3)
mini_mime (1.0.1)
mini_mime (1.0.2)
mini_portile2 (2.4.0)
minitest (5.11.3)
minitest (5.12.2)
multi_json (1.13.1)
multi_xml (0.6.0)
multipart-post (2.1.0)
......@@ -462,8 +462,8 @@ GEM
activesupport (>= 4.2.0, < 5.0)
nokogiri (~> 1.6)
rails-deprecated_sanitizer (>= 1.0.1)
rails-html-sanitizer (1.2.0)
loofah (~> 2.2, >= 2.2.2)
rails-html-sanitizer (1.3.0)
loofah (~> 2.3)
railties (4.2.11.1)
actionpack (= 4.2.11.1)
activesupport (= 4.2.11.1)
......@@ -533,13 +533,12 @@ GEM
nokogiri (>= 1.4.4)
rubyzip (>= 1.1.6)
ruby_dep (1.5.0)
ruby_parser (3.13.1)
ruby_parser (3.14.0)
sexp_processor (~> 4.9)
rubyzip (1.2.4)
safe_yaml (1.0.5)
sassc (2.0.1)
sassc (2.2.1)
ffi (~> 1.9)
rake
sassc-rails (2.1.1)
railties (>= 4.0.0)
sassc (>= 2.0)
......@@ -556,7 +555,7 @@ GEM
selenium-webdriver (3.142.4)
childprocess (>= 0.5, < 3.0)
rubyzip (~> 1.2, >= 1.2.2)
sexp_processor (4.12.0)
sexp_processor (4.13.0)
simplecov (0.12.0)
docile (~> 1.1.0)
json (>= 1.8, < 3)
......@@ -597,7 +596,7 @@ GEM
rack (>= 1.0.0)
thor (0.19.1)
thread_safe (0.3.6)
tilt (2.0.9)
tilt (2.0.10)
tins (1.20.2)
ttfunk (1.5.1)
turbo-sprockets-rails4 (1.2.5)
......
# Basic Setup
* Copy `config/database.yml.example` to `config/database.yml` and enter your database connection information.
* Copy `config/storage.yml.example` to `config/storage.yml` and enter your database connection information.
* Copy `.ruby-gemset.example` to `.ruby-gemset`.
* Copy `.ruby-version.example` to `.ruby-version`. (Skip this step if you want to use Docker)
* Reload directory to create rvm gemset.
# Installing a production ready server
## nokogiri
if there are errors with nokogiri compilation with new xcode7:
`gem install nokogiri -- --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/libxml2 --use-system-libraries`
## On a Ubuntu server
## openbabel
* Require
1. CMake (the `cmake` package in Ubuntu)
2. Eigen (the `libeigen2-dev` or `libeigen3-dev` package in Ubuntu)
3. Swig (the `swig`package in Ubuntu)
4. libxml2 (the `libxml2-dev` package in Ubuntu)
copy the installation script on a ubuntu server 18.04 (could work with another deb)
* openbabel will be automatically installed through `bundle install`
```
curl -o chemotion_ELN_install.sh -L https://git.scc.kit.edu/complat/chemotion_ELN_server/raw/development/scripts/install_production.sh
```
## rmagick
* `brew install imagemagick gs` for OSX
* `apt-get install libmagickcore-dev libmagickwand-dev` for linux
* if installing the rmagick gem fails you may try: `IM_PREFIX=$(brew list imagemagick 2>&1 | grep -E 'identify$' | sed 's/bin\/identify$//g') PKG_CONFIG_PATH=${IM_PREFIX}lib/pkgconfig/ C_INCLUDE_PATH=${IM_PREFIX}include/ImageMagick*/ gem install rmagick` (OSX only)
check the variables at the beginning of the file, but also check the whole script to see what it is doing.
## inkscape
* `sudo apt-get install inkscape` for Linux
* For Mac OSX, you need to install XQuartz before inkscape: `brew install Caskroom/cask/xquartz`, and `brew install homebrew/gui/inkscape`.
**TLDR**: it will ...
## Dataset previews
* `brew install imagemagick mplayer` for OSX
* `sudo apt-get -y install imagemagick mplayer` for Linux
* install OS package dependencies
* install passenger
* create a new user
* install ruby and nodejs for the user
* create a postgresql DB
* copy the chemotion_ELN code and prepare basic config files
* do a capistrano app deploy
* config nginx (NB: no ssl set) and UFW
When ready make the script executable and run it:
`chmod 700 chemotion_ELN_install.sh`
`sudo ./chemotion_ELN_install.sh`
After reboot the application should be up and running at the ip of the machine (http://...)
## Using Docker
This is a setup for a 'pseudo' production stage using passenger and aimed for user testing.
(For the development environment, change 'RAILS_ENV' to 'development' in docker-compose.yml)
**Make sure you have finished the BASIC SETUP FIRST**
1. Build the image from Dockerfile `docker-compose build` or pull the image: `docker-compose pull`
2. Initialize database FIRST:
* `docker-compose run app bundle exec rake db:create`
* `docker-compose run app bundle exec rake db:migrate`
* `docker-compose run app bundle exec rake db:seed` (optional). A "seed"
user will be inserted into the db with the information as below: template.moderator@eln.edu - password: "@eln.edu"
* `docker-compose run app rake ketcherails:import:common_templates` (optional)
3. Precompile assets: `docker-compose run app bundle exec rake assets:precompile`
4. To start the server: `docker-compose up` or start server and detach: `docker-compose up -d`
* Start interactive shell with docker: `docker-compose run app /bin/bash`
* NOTE: In this Docker image, we disabled the email verification progress
* To enable email confirmation, uncomment ":confirmable" at line 5 of `app/models/user.rb`, stop the `docker-compose` by `docker-compose stop` and start `docker-compose`.
# Basic Development Setup
* Copy `config/database.yml.example` to `config/database.yml` and enter your database connection information.
* Copy `config/storage.yml.example` to `config/storage.yml` and enter your database connection information.
* Copy `.ruby-gemset.example` to `.ruby-gemset`.
* Copy `.ruby-version.example` to `.ruby-version`. (Skip this step if you want to use Docker)
* Reload directory to create rvm gemset.
## Application Setup
* Execute `bundle install`.
......@@ -50,57 +79,79 @@ Production
`cp db/datacollectors.yml.example db/datacollectors.yml`
# Deployment notes
## Deployment notes
If you like to reset the database, you have to execute the following commands (under the assumption your production database is called `chemotion`)
```
sudo -u postgres psql -d chemotion -c 'DROP SCHEMA public CASCADE;CREATE SCHEMA public; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO public;'
```
The search feature uses the Postgres extension pg_trgm (http://www.postgresql.org/docs/9.3/static/pgtrgm.html). For the first installation on the production machine you have to install the `postgres-contrib` package in order to enable Postgres extensions.
Just restart Postgres after installing the package.
or alternatively, drop and recreate DB using rake task:
```
RAILS_ENV=production bundle exec rake db:drop db:create
```
If you like to reset the database (after `cap production deploy`) you have to execute the following commands (under the assumption your production database is called `chemotion`)
then, create DB extensions:
```
sudo -u postgres psql -d chemotion -c 'CREATE EXTENSION IF NOT EXISTS "pg_trgm"; CREATE EXTENSION IF NOT EXISTS "hstore"; CREATE EXTENSION IF NOT EXISTS "uuid-ossp";'
```
* `RAILS_ENV=production bundle exec rake db:drop db:create`
* `sudo -u postgres psql -d chemotion -c "CREATE EXTENSION pg_trgm;"`
* `RAILS_ENV=production bundle exec rake db:migrate db:seed`
and run DB migrations:
```
RAILS_ENV=production bundle exec rake db:migrate db:seed
```
# JS Setup & Testing
* Install `nvm`: `curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.32.0/install.sh | bash` (see https://github.com/creationix/nvm#installation)
## JS Setup & Testing
* Install `nvm`: `curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/0.34.0/install.sh | bash` (see https://github.com/nvm-sh/nvm#installation)
or for OSX: `brew install nvm && echo "source $(brew --prefix nvm)/nvm.sh" >> ~/.profile`
* Execute `nvm install` nvm will automatically use node 0.10.40 (in order to work with current jest-version)
* Execute `npm install -g npm@3.10.8`
* Execute `nvm install 10.15.3`
* Execute `npm install -g npm@6.11.3`
* Execute `npm install`.
# Mailing in Development Environment
## Mailing in Development Environment
Run `rake jobs:work` for asynchronous handling of email notifications. Run `mailcatcher` in your console and go to `localhost:1080` to see all sent mails.
# Icon Font
## Icon Font
* put new icons as SVG files (e.g. '<ICON_NAME>.svg') in `app/assets/images/svg_icons`
* run `rake icons:compile`
Icons are now available as css classes: '.icon-<ICON_NAME'
## FontCustom Dependencies
* `brew install fontforge --with-python`
* `brew install eot-utils`
# OS Dependencies
# Docker setup
This is a setup for a 'pseudo' production stage using passenger and aimed for user testing.
(For the development environment, change 'RAILS_ENV' to 'development' in docker-compose.yml)
**Make sure you have finished the BASIC SETUP FIRST**
## nokogiri
if there are errors with nokogiri compilation with new xcode7:
`gem install nokogiri -- --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/libxml2 --use-system-libraries`
1. Build the image from Dockerfile `docker-compose build` or pull the image: `docker-compose pull`
2. Initialize database FIRST:
* `docker-compose run app bundle exec rake db:create`
* `docker-compose run app bundle exec rake db:migrate`
* `docker-compose run app bundle exec rake db:seed` (optional). A "seed"
user will be inserted into the db with the information as below: template.moderator@eln.edu - password: "@eln.edu"
* `docker-compose run app rake ketcherails:import:common_templates` (optional)
3. Precompile assets: `docker-compose run app bundle exec rake assets:precompile`
4. To start the server: `docker-compose up` or start server and detach: `docker-compose up -d`
## openbabel
* Require
1. CMake (the `cmake` package in Ubuntu)
2. Eigen (the `libeigen2-dev` or `libeigen3-dev` package in Ubuntu)
3. Swig (the `swig`package in Ubuntu)
4. libxml2 (the `libxml2-dev` package in Ubuntu)
* Start interactive shell with docker: `docker-compose run app /bin/bash`
* NOTE: In this Docker image, we disabled the email verification progress
* openbabel will be automatically installed through `bundle install`
* To enable email confirmation, uncomment ":confirmable" at line 5 of `app/models/user.rb`, stop the `docker-compose` by `docker-compose stop` and start `docker-compose`.
## rmagick
* `brew install imagemagick gs` for OSX
* `apt-get install libmagickcore-dev libmagickwand-dev` for linux
* if installing the rmagick gem fails you may try: `IM_PREFIX=$(brew list imagemagick 2>&1 | grep -E 'identify$' | sed 's/bin\/identify$//g') PKG_CONFIG_PATH=${IM_PREFIX}lib/pkgconfig/ C_INCLUDE_PATH=${IM_PREFIX}include/ImageMagick*/ gem install rmagick` (OSX only)
## inkscape
* `sudo apt-get install inkscape` for Linux
* For Mac OSX, you need to install XQuartz before inkscape: `brew install Caskroom/cask/xquartz`, and `brew install homebrew/gui/inkscape`.
## Dataset previews
* `brew install imagemagick mplayer` for OSX
* `sudo apt-get -y install imagemagick mplayer` for Linux
## FontCustom Dependencies
* `brew install fontforge --with-python`
* `brew install eot-utils`
#!/usr/bin/env bash
## This is a script to install a production ready chemotion_ELN server
## with NGINX/PASSENGER/RAILS/POSTGRESQL on a Ubuntu 18.04 machine
## Could work on another debian but passenger install (part 2)
## should be edited accordingly
set -euo pipefail
############################################
############# VARIABLES ####################
## CHEMOTION ELN GIT REPOSITORY
REPO='https://git.scc.kit.edu/complat/chemotion_ELN_server'
BRANCH=development
## user account name (to be created or to be used)
PROD=production
## PROD HOME set in part 3
# PROD_HOME=$(eval echo "~$PROD")
## RUBY
RUBY_VERSION=2.5.6
BUNDLER_VERSION=1.17.3
## NODEJS
NVM_VERSION='v0.34.0'
NODE_VERSION=10.15.3
NPM_VERSION=6.11.3
## TMP DIR (has to be acccesible to install and PROD user)
TMP_DIR=/tmp/chemotion_stage
## INSTALLATION DIRECTORY
PROD_DIR=/var/www/chemotion_ELN
## APPLICATION PORT
PORT=4001
## POSTGRESQL DB
DB_ROLE=chemotion_prod
DB_NAME=chemotion_prod
DB_PW=$(openssl rand -base64 8 | sed 's~/~~g')
DB_HOST=localhost
DB_PORT=5432
NCPU=$(grep -c ^processor /proc/cpuinfo)
############################################
######### INSTALLATION PARTS ##############
############################################
### comment line out to skip a part#########
PART_1='deb dependencies'
PART_2='phusionpassenger'
PART_3='create user'
PART_4='rvm and ruby'
PART_5='nvm and npm'
PART_6='prepare postgresql DB'
PART_7='prepare production app directories and config'
PART_71='reset DB pw'
PART_8='prepare first deploy and deploy application code'
PART_9='prepare boot start'
PART_10='configure NGINX and UFW'
############################################
############################################
#### INSTALLATION SCRIPT STARTS HERE #######
############################################
############################################
GRE='\033[0;32m'
YEL='\033[0;33m'
RED='\033[0;31m'
NOC='\033[0m'
red() {
printf "${RED}${1:-}${NOC}\n"
}
yellow() {
printf "${YEL}${1:-}${NOC}\n"
}
green() {
printf "${GRE}${1:-}${NOC}\n"
}
sharpi() {
green "##########################################"
yellow "${1:-}"
green "##########################################"
}
rm_tmp() {
yellow 'removing tmp files..'
sudo rm -rf $TMP_DIR
}
trap "rm_tmp; red 'An error has occured'" ERR
############################################
############################################
sharpi 'PART 1'
description="installing debian dependencies"
############################################
if [ "${PART_1:-}" ]; then
sharpi "$description"
# sudo add-apt-repository -y ppa:inkscape.dev/stable
sudo apt-get -y update
# sudo apt-get install inkscape
sudo apt-get -y install inkscape ca-certificates apt-transport-https git curl gnupg2 \
autoconf automake bison libffi-dev libgdbm-dev libncurses5-dev \
libyaml-dev sqlite3 libgmp-dev libreadline-dev libssl-dev \
postgresql postgresql-client postgresql-contrib libpq-dev \
imagemagick libmagic-dev libmagickcore-dev libmagickwand-dev \
swig cmake libeigen3-dev \
libxslt-dev libxml2-dev \
libsass-dev \
fonts-liberation gconf-service libgconf-2-4 \
libnspr4 libnss3 libpango1.0-0 libxss1 \
xfonts-cyrillic xfonts-100dpi xfonts-75dpi xfonts-base xfonts-scalable \
tzdata python-dev libsqlite3-dev libboost-all-dev p7zip-full \
nginx ranger htop \
--fix-missing
green "done $description\n"
else
yellow "skip $description\n"
fi
############################################
############################################
sharpi 'PART 2'
description='installing passenger'
############################################
if [ "${PART_2:-}" ]; then
sharpi "$description"
## https://www.phusionpassenger.com/library/install/nginx/install/oss/bionic/
sudo apt-get install -y dirmngr gnupg
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 561F9B9CAC40B2F7
sudo apt-get install -y apt-transport-https ca-certificates
sudo sh -c 'echo deb https://oss-binaries.phusionpassenger.com/apt/passenger bionic main > /etc/apt/sources.list.d/passenger.list'
sudo apt-get update
sudo apt-get install -y libnginx-mod-http-passenger
if [ ! -f /etc/nginx/modules-enabled/50-mod-http-passenger.conf ]; then
sudo ln -s /usr/share/nginx/modules-available/mod-http-passenger.load /etc/nginx/modules-enabled/50-mod-http-passenger.conf
fi
sudo ls /etc/nginx/conf.d/mod-http-passenger.conf
sudo /usr/bin/passenger-config validate-install
green "done $description\n"
else
yellow "skip $description\n"
fi
############################################
############################################
sharpi 'PART 3'
description="creating production user $PROD"
############################################
if [ "${PART_3:-}" ]; then
sharpi "$description"
if id -u $PROD > /dev/null 2>&1; then
yellow "user $PROD already exists"
else
yellow "creating user '$PROD' with home directory"
sudo useradd -m $PROD
echo $PROD:$(openssl rand -base64 8) | sudo chpasswd
sudo usermod -s /bin/bash $PROD
fi
green "done $description\n"
else
yellow "skip $description\n"
fi
PROD_HOME=$(eval echo "~$PROD")
############################################
############################################
sharpi 'PART 4'
description="installing rvm and ruby $RUBY_VERSION"
############################################
if [ "${PART_4:-}" ]; then
sharpi "$description"
sudo -H -u $PROD bash -c 'gpg2 --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB'
sudo -H -u $PROD bash -c "curl -sSL https://get.rvm.io | bash -s stable --ruby=$RUBY_VERSION --auto-dotfiles"
sudo -H -u $PROD bash -c "source ~/.rvm/scripts/rvm && rvm use $RUBY_VERSION && gem install bundler -v $BUNDLER_VERSION "
green "done $description\n"
else
yellow "skip $description\n"
fi
############################################
############################################
sharpi 'PART 5'
description="installing nvm and node $NODE_VERSION"
############################################
if [ "${PART_5:-}" ]; then
sharpi "$description"
sudo -H -u $PROD bash -c "curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/$NVM_VERSION/install.sh | bash"
sudo -H -u $PROD bash -c "source ~/.nvm/nvm.sh && nvm install $NODE_VERSION"
sudo -H -u $PROD bash -c "source ~/.nvm/nvm.sh && nvm use $NODE_VERSION && npm install -g npm@$NPM_VERSION"
green "done $description\n"
else
yellow "skip $description\n"
fi
###########################################
############################################
sharpi 'PART 6'
description="Prepare postgresql DB"
############################################
if [ "${PART_6:-}" ]; then
sharpi "$description"
sudo -u postgres psql -c " CREATE ROLE $DB_ROLE LOGIN CREATEDB NOSUPERUSER PASSWORD '$DB_PW';" || yellow "ROLE $DB_ROLE already exists and will be used!"
sudo -u postgres psql -c " CREATE DATABASE $DB_NAME OWNER $DB_ROLE;" || { red "DATABASE $DB_NAME already exists! Skip this part if you want to use this DB"; exit ; }
sudo -u postgres psql -d $DB_NAME -c ' CREATE EXTENSION IF NOT EXISTS "pg_trgm"; CREATE EXTENSION IF NOT EXISTS "hstore"; CREATE EXTENSION IF NOT EXISTS "uuid-ossp";'
green "done $description\n"
else
yellow "skip $description\n"
fi
#sudo -u postgres psql -c "ALTER USER $DB_ROLE PASSWORD '$pw';"
############################################
############################################
sharpi 'PART 7'
description="Preparing production directories and configuration files"
############################################
if [ "${PART_7:-}" ]; then
sharpi "$description"
pwd=$PROD_DIR/shared
sudo mkdir -p $PROD_DIR/releases $PROD_DIR/repo \
$pwd/backup/deploy_backup $pwd/backup/weekly_backup \
$pwd/config $pwd/log $pwd/node_modules \
$pwd/public \
$pwd/tmp/pids $pwd/tmp/cache $pwd/tmp/sockets $pwd/tmp/uploads
echo $RUBY_VERSION | sudo tee $pwd/.ruby-version
echo "SECRET_KEY_BASE='$(dd if=/dev/urandom bs=32 count=1 2>/dev/null | sha512sum -b | sed 's/ .*//')'" | sudo tee $pwd/.env >/dev/null
echo | sudo tee -a $pwd/.env <<EOL
DB_NAME='$DB_NAME'
DB_ROLE='$DB_ROLE'
DB_PW='$DB_PW'
DB_HOST='$DB_HOST'
DB_PORT=$DB_PORT
EOL
git clone --branch $BRANCH --depth 1 $REPO $TMP_DIR
\cp -ru $TMP_DIR/public/images $PROD_DIR/shared/public/.
\cp -u $TMP_DIR/config/storage.yml.example $pwd/config/storage.yml
\cp -u $TMP_DIR/config/secrets.yml $pwd/config/secrets.yml
rm_tmp
echo | sudo tee $pwd/config/database.yml <<EOL
production:
adapter: postgresql
encoding: unicode
database: <%=ENV['DB_NAME']%>
pool: 5
username: <%=ENV['DB_ROLE']%>
password: <%=ENV['DB_PW']%>
host: <%=ENV['DB_HOST']%>
port: <%=ENV['DB_PORT']%>
EOL
# SET storage config
echo | sudo tee $pwd/config/storage.yml <<EOL
production:
:primary_store: 'local'
:secundary_store: ''
:stores:
:tmp:
:data_folder: 'tmp/uploads/production/'
:thumbnail_folder: 'tmp/uploads/production'
:local:
:data_folder: 'uploads'
:thumbnail_folder: 'uploads'
EOL