root@root:~$ docker images | grep ubuntu ubuntu latest 0ef2e08ed3fa 6 weeks ago 130MB
docker run -d -it -p 2222:22 ubuntu:16.04 docker ps // container_id docker attach container_id
apt-get update apt-get install openssh-server service ssh start
adduser deployer
ssh -p 2222 deployer@0.0.0.0
ssh-keygen -f "/home/USER/.ssh/known_hosts" -R [0.0.0.0]:2222
deployer@e2cad98fb69d:~$
apt-get install git
apt-get install bzip2 apt-get install -y libssl-dev libreadline-dev zlib1g-dev apt-get install build-essential
rbenv install -v 2.3.1 rbenv global 2.3.1 gem install rails -v 4.2.7.1
apt-get install postgresql postgresql-contrib service postgresql start
su - postgres psql \password create database mina_deploy_example; //
apt-get install nginx
nano /etc/nginx/sites-available/default
upstream mysite { server unix:///home/deployer/mina-deploy-example/shared/tmp/sockets/puma.sock fail_timeout=0; } server { listen 80; listen [::]:80; root /home/deployer/mina-deploy-example/current/public; location ~ ^/assets/ { expires max; gzip_static on; gzip_vary on; add_header Cache-Control public; break; } location ~ ^/system/ { expires max; gzip_static on; gzip_vary on; add_header Cache-Control public; break; } location / { proxy_pass http://mysite; # match the name of upstream directive which is defined above proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } location ~ ^/(500|404|422).html { root /home/deployer/mina-deploy-example/current/public; } error_page 500 502 503 504 /500.html; error_page 404 /404.html; error_page 422 /422.html; client_max_body_size 4G; keepalive_timeout 10; }
ssh -p 2222 deployer@0.0.0.0 git config --global user.name "Some User" git config --global user.email "someuser@example.com" ssh-keygen -t rsa -b 4096 -C "someuser@example.com" ssh -T git@github.com
cat ~/.ssh/id_rsa.pub
gem 'mina' gem 'mina-puma', require: false gem 'mina-nginx', require: false
require 'mina/bundler' require 'mina/rails' require 'mina/git' require 'mina/rbenv' require 'mina/nginx' require 'mina/puma' set :application_name, 'mina-deploy-example' set :domain, '127.0.0.1' set :port, '2222' set :user, 'deployer' set :shared_dirs, fetch(:shared_dirs, []).push('tmp', 'log', 'public/uploads', 'public/system') set :shared_files, fetch(:shared_files, []).push('config/puma.rb', 'config/database.yml', 'config/secrets.yml') set :deploy_to, '/home/deployer/mina-deploy-example' set :repository, 'git@github.com:rails-guides/mina-deploy-example.git' set :branch, 'master' set :rails_env, 'production'
task :environment do invoke :'rbenv:load' end task setup: :environment do command %{mkdir -p "#{fetch(:shared_path)}/log"} command %{chmod g+rx,u+rwx "#{fetch(:shared_path)}/log"} command %{mkdir -p "#{fetch(:shared_path)}/config"} command %{chmod g+rx,u+rwx "#{fetch(:shared_path)}/config"} command %{touch "#{fetch(:shared_path)}/config/puma.rb"} command %{touch "#{fetch(:shared_path)}/config/database.yml"} command %{touch "#{fetch(:shared_path)}/config/secrets.yml"} command %{mkdir -p "#{fetch(:shared_path)}/tmp/sockets"} command %{chmod g+rx,u+rwx "#{fetch(:shared_path)}/tmp/sockets"} command %{mkdir -p "#{fetch(:shared_path)}/tmp/pids"} command %{chmod g+rx,u+rwx "#{fetch(:shared_path)}/tmp/pids"} end
task deploy: :environment do deploy do invoke :'git:clone' invoke :'deploy:link_shared_paths' on :build do invoke :'bundle:install' invoke :'rails:db_migrate' invoke :'rails:assets_precompile' invoke :'deploy:cleanup' end on :launch do invoke :'puma:restart' end end end
directory '/home/deployer/mina-deploy-example/current' rackup '/home/deployer/mina-deploy-example/current/config.ru' environment 'production' daemonize true pidfile '/home/deployer/mina-deploy-example/shared/tmp/pids/puma.pid' state_path '/home/deployer/mina-deploy-example/shared/tmp/sockets/puma.state' bind 'unix:///home/deployer/mina-deploy-example/shared/tmp/sockets/puma.sock' activate_control_app 'unix:///home/deployer/mina-deployexample/shared/tmp/sockets/pumactl.sock'
production: host: localhost database: mina_deploy_example adapter: postgresql encoding: unicode username: postgres password: 123
production: secret_key_base: SECRET_KEY_BASE
gem install bundler apt-get install ruby-dev gem install json -v '1.8.6' gem install pg -v '0.20.0' apt-get install postgresql postgresql-contrib libpq-dev gem install uglifier apt-get install nodejs apt-get install imagemagick
mina deploy mina puma:start
sudo ssh -f -N -L 80:localhost:80 deployer@0.0.0.0 -p 2222
Source: https://habr.com/ru/post/328582/
All Articles