Skip to content

Commit

Permalink
Merge branch 'feature/loomio' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
fauno committed Mar 4, 2015
2 parents b95b8bb + 7617a88 commit 598ca01
Showing 1 changed file with 77 additions and 0 deletions.
77 changes: 77 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,83 @@ des_key=$(shell dd if=/dev/urandom bs=24 count=1 2>/dev/null| base64 -w 23 | hea
chown nobody:http $@
chmod 640 $@

# Deploy de loomio
# Necesitamos instalar postgresql
/var/lib/postgresql/9.3/main:
apt-get install --yes postgresql postgresql-client postgresql-contrib

# Acá van las gemas compartidas
/srv/http/gemas.partidopirata.com.ar:
install --directory --mode 770 --owner http --group http $@
chmod g+s $@

/home/app: /home/%: /var/lib/postgresql/9.3/main
getent passwd $* \
|| useradd --home-dir $@ \
--create-home \
--shell /bin/bash \
--gid http \
$*
cat ssh/*.pub >$@/.ssh/authorized_keys
chmod 700 $@
sudo -iu postgres createuser --createdb app
sudo -iu app createdb loomio
sudo -iu postgresql psql -c "create extension hstore;" loomio

# Preparar el directorio
/srv/http/consenso.partidopirata.com.ar: /home/app
install --directory --mode 750 --owner app --group http $@
chmod g+s $@

# Preparar el dotenv para el deploy
cookie_token=$(shell dd if=/dev/urandom bs=128 count=1 2>/dev/null| base64 -w 127 | head -n1)
devise_secret=$(shell dd if=/dev/urandom bs=128 count=1 2>/dev/null| base64 -w 127 | head -n1)
/srv/http/consenso.partidopirata.com.ar/shared/.env: %/.env: /srv/http/consenso.partidopirata.com.ar
install -dm700 $*
echo "FORCE_SSL=true" >$@
echo "RACK_ENV=production" >>$@
echo "SECRET_COOKIE_TOKEN=$(cookie_token)" >>$@
echo "DEVISE_SECRET=$(devise_secret)" >>$@
echo "CANONICAL_HOST=consenso.partidopirata.com.ar" >>$@
# los simpaticos de loomio creen que todos los dominios tienen dos
# elementos
echo "DEFAULT_SUBDOMAIN=consenso.partidopirata" >>$@
chmod 600 $@
chown -R app:http $*

/etc/ssl/certs/consenso.partidopirata.com.ar.crt:
cd /etc/ssl ; echo "consenso.partidopirata.com.ar" >>domains
cd /etc/ssl ; make certs/consenso.partidopirata.com.ar.crt
cd /etc/ssl ; chmod 640 private/consenso.partidopirata.com.ar.key
cd /etc/ssl ; chmod 644 certs/consenso.partidopirata.com.ar.crt

# Crea la configuración del sitio en nginx
/etc/nginx/sites/consenso.partidopirata.com.ar.conf: /etc/ssl/certs/consenso.partidopirata.com.ar.crt /srv/http/consenso.partidopirata.com.ar/shared/.env
echo "server {" >$@
echo " server_name consenso.partidopirata.com.ar;" >>$@
echo " include \"snippets/ssl-only.conf\";" >>$@
echo "}" >>$@
echo >>$@
echo "server {" >>$@
echo " server_name consenso.partidopirata.com.ar;" >>$@
echo " ssl_certificate /etc/ssl/certs/consenso.partidopirata.com.ar.crt;" >>$@
echo " ssl_certificate_key /etc/ssl/private/consenso.partidopirata.com.ar.key;" >>$@
echo " passenger_ruby /home/app/.rbenv/shims/ruby;" >>$@
echo " include \"snippets/ssl.conf\";" >>$@
echo " include \"snippets/capistrano.conf\";" >>$@
echo "}" >>$@
nginx -t

# instala y compila ruby 2.2.0
/home/app/.rbenv: %/.rbenv:
sudo -iu app git clone https://github.com/sstephenson/rbenv.git $@
sudo -iu app git clone https://github.com/sstephenson/ruby-build.git $@/plugins/ruby-build
echo 'export PATH="$$HOME/.rbenv/bin:$$PATH"' >>$*/.bash_profile
echo 'eval "$$(rbenv init -)"' >> $*/.bash_profile
sudo -iu app rbenv install 2.2.0
sudo -iu app rbenv global 2.2.0
sudo -iu app rbenv exec gem install bundler

# Un shortcut para declarar reglas sin contraparte en el filesystem
# Nota: cada vez que se usa uno, todas las reglas que llaman a la regla
# phony se ejecutan siempre
Expand Down

0 comments on commit 598ca01

Please sign in to comment.