Skip to content

Instantly share code, notes, and snippets.

@breim
Last active September 22, 2019 07:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save breim/a6389c15ab589827cff81f9763585841 to your computer and use it in GitHub Desktop.
Save breim/a6389c15ab589827cff81f9763585841 to your computer and use it in GitHub Desktop.
Quiz deploy
sudo apt-get update -y
sudo apt-get upgrade -y
# Rvm
curl -L https://get.rvm.io | bash -s stable
source ~/.rvm/scripts/rvm
rvm requirements
rvm install 2.5.3
gem install rails
# Usamos pg 10
sudo apt-get install postgresql postgresql-contrib libpq-dev
sudo su postgres
createuser -P -s -e deploy
(crie a senha, vai ser usada posteriormente com o usuário deploy na conf do rails)
Acesse
sudo nano /etc/postgresql/10/main/pg_hba.conf
e deixe assim
# Database administrative login by Unix domain socket
local all postgres trust
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all trust
# IPv4 local connections:
host all all 127.0.0.1/32 trust
# IPv6 local connections:
host all all ::1/128 trust
# Allow replication connections from localhost, by a user with the
# replication privilege.
#local replication postgres peer
#host replication postgres 127.0.0.1/32 md5
#host replication postgres ::1/128 md5
# passenger + nginx
gem install passenger
sudo chown -R `whoami` /opt
passenger-install-nginx-module --auto-download --auto
# configure o nginx agora
sudo nano /opt/nginx/conf/nginx.conf
# Use como base esse arquivo para o nginx
# https://gist.github.com/breim/9188ff07ee7a0910bd53763752b6713e
# voltar ao normal a folder
sudo chown -R root /opt
# fazer nginx iniciar sozinho quando restartar a maquina
wget -O init-deb.sh http://library.linode.com/assets/660-init-deb.sh
sudo mv init-deb.sh /etc/init.d/nginx
sudo chmod +x /etc/init.d/nginx
sudo /usr/sbin/update-rc.d -f nginx defaults
# Git
# gere a chave rsa ssh e adicione no seu repositório do bibucket em configurações:
# https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/
# depois
# git clone git@bitbucket.org:passarme/educational.git
git clone https://gitlab.dev.br-mediagroup.com/breim/quiz.git
# Agora vamos instalar as dependencias da app
cd quiz
bundle install
# Instale o figaro, ele é responsável por gerenciar as senhas da app
figaro install
# Adicione as senhas dentro do arquivo
sudo nano config/application.yml
# Crie o bancos de dados
RAILS_ENV=production rake db:create
RAILS_ENV=production rake db:migrate
# Crie os assets
RAILS_ENV=production rake assets:precompile
# SSL
# https://www.digitalocean.com/community/tutorials/how-to-secure-nginx-with-let-s-encrypt-on-ubuntu-16-04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment