SlideShare ist ein Scribd-Unternehmen logo
1 von 38
LESSON 2
RVM, GIT, RAILS, HEROKU
Pavel Tsiukhtsiayeu
github.com/paveltyk
TODO
• Git
   • Install
   • Configure
• RVM
   • Install RVM
   • Install Ruby
   • Create Gemset
• Rails
   • Install
   • Generate project
   • First commit
   • Start server
• Heroku
   • Install & Configure
   • Push Rails app to Heroku
   • Make it WORK
• Tips & Tricks
Git :: install
• $ sudo apt-get install git-core
Git :: configure
• $ git config --global user.name "PavelT"
• $ git config --global user.email paveltyk@gmail.com




Where does git store its settings?
• /etc/gitconfig (--system)
• ~/.gitconfig (--global)
• .git/config
Git :: configure
• $ git config --list

• user.name=PavelT
• user.email=paveltyk@gmail.com
• color.ui=true
• push.default=tracking

• $ git config user.name

• PavelT

• At least have this 4
Git :: install and configure
• Q&A?
RVM :: install
• $ sudo apt-get install curl
• $ curl –L https://get.rvm.io | bash –s stable


• For RVM to work properly, you have to set the 'Run
  command as login shell' checkbox at Edit / Profile
  Preferences / Title and Commands in Gnome terminal
• More details here:
       https://rvm.io/integration/gnome-terminal
RVM :: install Ruby
• $ rvm requirements

• Requirements for Linux "Ubuntu 12.04.1 LTS”
• ………
• Additional Dependencies:
• # For Ruby / Ruby HEAD (MRI, Rubinius, & REE), install the following:

                        build-essential openssl libreadline6
• ruby: /usr/bin/apt-get install
  libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev
  libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev
  autoconf libc6-dev ncurses-dev automake libtool bison
  subversion pkg-config
RVM :: install Ruby
• $ sudo apt-get install build-essential openssl libreadline6
 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev
 libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev
 autoconf libc6-dev ncurses-dev automake libtool bison
 subversion pkg-config
RVM :: install Ruby
• $ rvm list known

• # MRI Rubies
• [ruby-]1.8.6[-p420]
• ...
• [ruby-]1.9.3[-p194]
• ...
• # Jruby
• ...


• $ rvm install 1.9.3
RVM :: gemset
• $ rvm use 1.9.3
• $ which ruby

• /home/pavelt/.rvm/rubies/ruby-1.9.3-p194/bin/ruby

• $ rvm gemset create first-app
• $ rvm gemset use first-app

• How to easily switch gemsets & Ruby versions [Tips & Tricks]
RVM
• Q&A?
Rails :: install
• $ gem install rails

• Fetching: i18n-0.6.1.gem (100%)
• Fetching: rails-3.2.8.gem (100%)
• ...
• 29 gems installed
• Successfully installed i18n-0.6.1
• ...
• Installing ri documentation for i18n-0.6.1..
• Installing RDoc documentation for rack-cache-1.2...


• Ri and RDoc are slow [see Tips & Tricks]
Rails :: new app
• $ rails new first-app

• create README.rdoc
• create Rakefile
• ……
• Fetching gem metadata from https://rubygems.org/.........
• Using rake (0.9.2.2)
• Using i18n (0.6.1)
• …..
• Your bundle is complete! Use `bundle show [gemname]`
 to see where a bundled gem is installed.
Rails :: app skeleton (partial)
• app/ - core application code (controllers, views, models…)
• config/ - application configuration
• db/ - DB related files (migrations, seeds, etc)
• lib/ - library modules
• log/ - application log files
• public/ - publicly accessible data
• Gemfile - app gem requirements
• .gitignore – patterns for files that should be ignored by git
Git :: init repo & initial commit
• $ cd first-app
• $ git init

• Initialized empty Git repository in /home/pavelt/projects/first-app/.git/

• $ git commit --allow-empty -m 'Initial commit’

• [master (root-commit) 6f32ce8] Initial commit
Git :: add files & commit
• $ git status

• # On branch master
• # Untracked files:
• # (use "git add <file>..." to include in what will be committed)
• #
• #    .gitignore
•   # Gemfile
•   # Gemfile.lock
•   …….
•   nothing added to commit but untracked files present (use "git
    add" to track)
Git :: add files & commit
• $ git add .
• git commit - m ’Initial rails project’
Rails :: start server
• rails s
• => Booting WEBrick
• => Rails 3.2.8 application starting in development on
    http://0.0.0.0:3000
•   => Call with -d to detach
•   => Ctrl-C to shutdown server
•   [2012-09-23 19:46:46] INFO WEBrick 1.3.1
•   [2012-09-23 19:46:46] INFO ruby 1.9.2 (2011-07-09)
    [x86_64-darwin11.2.0]
•   [2012-09-23 19:46:46] INFO WEBrick::HTTPServer#start:
    pid=32565 port=3000
Rails :: http://localhost:3000
Rails :: if rails server failed
• If failed with:

• home/pavelt/.rvm/gems/ruby-1.9.3-p194/gems/execjs-
 1.4.0/lib/execjs/runtimes.rb:51:in `autodetect': Could not
 find a JavaScript runtime. See
 https://github.com/sstephenson/execjs for a list of
 available runtimes. (ExecJS::RuntimeUnavailable)

• Uncomment therubyracer gem in ./Gemfile

• bundle install
• git add Gemfile*
• git commit -m ‘Added gem therubyracer’
Heroku
• What is Heroku?
• Heroku is a cloud application platform – a new way of
    building and deploying web apps. (Heroku | About)
•   Heroku is a cloud platform as a service (PaaS) supporting
    several programming languages. (Wikipedia)
•   Heroku = Easy deployment
•   Heroku = No server managing
•   Heroku = Scale with 1 command
•   Heroku = Read-only file system
Heroku :: deployment
• How to deploy to Heroku?
• Simply push to master branch of your Heroku git repo
• $ git push heroku master
Heroku :: install & configure
• $ gem install heroku

• Register at Heroku sign up page
• https://api.heroku.com/signup
• $ heroku login

• Enter your Heroku credentials.
• Email: paveltyk@gmail.com
• Password (typing will be hidden):
• Authentication successful.

• More info: https://toolbelt.heroku.com
Heroku :: first app
• $ heroku create pavelt-first-app
• Creating pavelt-first-app... done, stack is cedar
• http://pavelt-first-app.herokuapp.com/ | git@heroku.com:pavelt-
  first-app.git
• Git remote heroku added

• $ git remote -v

• heroku git@heroku.com:pavelt-first-app.git (fetch)
• heroku git@heroku.com:pavelt-first-app.git (push)
Heroku :: first app
• Go to http://pavelt-first-app.herokuapp.com
Heroku :: first app
• $ git push heroku master

• The authenticity of host 'heroku.com (50.19.85.156)' can't be
    established.
•   RSA key fingerprint is
    8b:48:5e:67:0e:c9:16:47:32:f2:87:0c:1f:c8:60:ad.
•   Are you sure you want to continue connecting (yes/no)? yes
•   Warning: Permanently added 'heroku.com,50.19.85.156' (RSA)
    to the list of known hosts.
•   Permission denied (publickey).
•   fatal: The remote end hung up unexpectedly
Heroku :: first app
• $ heroku keys:add

• Could not find an existing public key.
• Would you like to generate one? [Yn] y
• Generating new SSH public key.
• Uploading SSH public key /home/pavelt/.ssh/id_rsa.pub... done


• $ git push heroku master
Heroku :: first app
• Counting objects: 73, done.
• Compressing objects: 100% (58/58), done.
• ….
• -----> Heroku receiving push
• -----> Ruby/Rails app detected
• -----> Installing dependencies using Bundler version 1.2.0
• …


• Installing sqlite3 (1.3.6) with native extensions
• Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native
    extension.
•   Failed to install gems via Bundler.
•   Detected sqlite3 gem which is not supported on Heroku.
•   http://devcenter.heroku.com/articles/how-do-i-use-sqlite3-for-development
•   Heroku push rejected, failed to compile Ruby/rails app
Heroku :: first app
• Remove `gem ‘sqlite3’` line from ./Gemfile, update bundle and commit

• $ bundle install
• git commit -am ‘Removed SQLite3 gem’

• $ git push heroku master
• Counting objects: 73, done.
• ….
• -----> Heroku receiving push
• -----> Ruby/Rails app detected
• -----> Installing dependencies using Bundler version 1.2.0
• …
• Your bundle is complete! It was installed into ./vendor/bundle
• …
• -----> Writing config/database.yml to read from DATABASE_URL
• -----> Preparing app for Rails asset pipeline
• -----> Launching... done, v7
•      http://pavelt-first-app.herokuapp.com deployed to Heroku
Heroku
• Q&A?
Tips & Tricks :: .rvmrc
• Automatically change Ruby version and Gemset
• ./.rvmrc
• rvm use 1.9.3@first-app --create
Tips & Tricks :: disable Ri & RDoc
• How to disable Ri and Rdoc?
• ~/.gemrc

• install: --no-ri --no-rdoc
• update: --no-ri --no-rdoc
Tips & Tricks :: informative prompt
• How to make prompt more informative?
• ~/.bashrc

•   export GIT_PS1_SHOWDIRTYSTATE=true
•   export GIT_PS1_SHOWUNTRACKEDFILES=true
•   export GIT_PS1_SHOWSTASHSTATE=true
•   PS1='[$(~/.rvm/bin/rvm-prompt)]u:W[$(__git_ps1 "%s")] '

Weitere ähnliche Inhalte

Was ist angesagt?

Deploying Symfony | symfony.cat
Deploying Symfony | symfony.catDeploying Symfony | symfony.cat
Deploying Symfony | symfony.catPablo Godel
 
Git: An introduction of plumbing and porcelain commands
Git: An introduction of plumbing and porcelain commandsGit: An introduction of plumbing and porcelain commands
Git: An introduction of plumbing and porcelain commandsth507
 
Code reviews vs Pull requests
Code reviews vs Pull requestsCode reviews vs Pull requests
Code reviews vs Pull requestsTim Pettersen
 
Ninja Git: Save Your Master
Ninja Git: Save Your MasterNinja Git: Save Your Master
Ninja Git: Save Your MasterNicola Paolucci
 
20150317 firefox os_studymtg_engver
20150317 firefox os_studymtg_engver20150317 firefox os_studymtg_engver
20150317 firefox os_studymtg_engverNaoki Sekiguchi
 
Basic Git commands
Basic Git commandsBasic Git commands
Basic Git commandsJitendra Zaa
 
Deploying WP Multisite to Heroku
Deploying WP Multisite to HerokuDeploying WP Multisite to Heroku
Deploying WP Multisite to HerokuJussi Kinnula
 
Create Development and Production Environments with Vagrant
Create Development and Production Environments with VagrantCreate Development and Production Environments with Vagrant
Create Development and Production Environments with VagrantBrian Hogan
 
Noah Zoschke at Waza 2013: Heroku Secrets
Noah Zoschke at Waza 2013: Heroku SecretsNoah Zoschke at Waza 2013: Heroku Secrets
Noah Zoschke at Waza 2013: Heroku SecretsHeroku
 
Git Workshop : Git On The Server
Git Workshop : Git On The ServerGit Workshop : Git On The Server
Git Workshop : Git On The ServerWildan Maulana
 
Creating and Deploying Static Sites with Hugo
Creating and Deploying Static Sites with HugoCreating and Deploying Static Sites with Hugo
Creating and Deploying Static Sites with HugoBrian Hogan
 
以 Laravel 經驗開發 Hyperf 應用
以 Laravel 經驗開發 Hyperf 應用以 Laravel 經驗開發 Hyperf 應用
以 Laravel 經驗開發 Hyperf 應用Shengyou Fan
 
GIT | Distributed Version Control System
GIT | Distributed Version Control SystemGIT | Distributed Version Control System
GIT | Distributed Version Control SystemMohammad Imam Hossain
 
2012 coscup - Build your PHP application on Heroku
2012 coscup - Build your PHP application on Heroku2012 coscup - Build your PHP application on Heroku
2012 coscup - Build your PHP application on Herokuronnywang_tw
 
Christian Strappazzon - Presentazione Python Milano - Codemotion Milano 2017
Christian Strappazzon - Presentazione Python Milano - Codemotion Milano 2017Christian Strappazzon - Presentazione Python Milano - Codemotion Milano 2017
Christian Strappazzon - Presentazione Python Milano - Codemotion Milano 2017Codemotion
 
Rugged Driven Development with Gauntlt
Rugged Driven Development with GauntltRugged Driven Development with Gauntlt
Rugged Driven Development with GauntltJames Wickett
 

Was ist angesagt? (20)

Deploying Symfony | symfony.cat
Deploying Symfony | symfony.catDeploying Symfony | symfony.cat
Deploying Symfony | symfony.cat
 
Git: An introduction of plumbing and porcelain commands
Git: An introduction of plumbing and porcelain commandsGit: An introduction of plumbing and porcelain commands
Git: An introduction of plumbing and porcelain commands
 
Code reviews vs Pull requests
Code reviews vs Pull requestsCode reviews vs Pull requests
Code reviews vs Pull requests
 
Git & Github for beginners
Git & Github for beginnersGit & Github for beginners
Git & Github for beginners
 
Ninja Git: Save Your Master
Ninja Git: Save Your MasterNinja Git: Save Your Master
Ninja Git: Save Your Master
 
Becoming a Git Master
Becoming a Git MasterBecoming a Git Master
Becoming a Git Master
 
Git presentation
Git presentationGit presentation
Git presentation
 
20150317 firefox os_studymtg_engver
20150317 firefox os_studymtg_engver20150317 firefox os_studymtg_engver
20150317 firefox os_studymtg_engver
 
Basic Git commands
Basic Git commandsBasic Git commands
Basic Git commands
 
Deploying WP Multisite to Heroku
Deploying WP Multisite to HerokuDeploying WP Multisite to Heroku
Deploying WP Multisite to Heroku
 
Create Development and Production Environments with Vagrant
Create Development and Production Environments with VagrantCreate Development and Production Environments with Vagrant
Create Development and Production Environments with Vagrant
 
Noah Zoschke at Waza 2013: Heroku Secrets
Noah Zoschke at Waza 2013: Heroku SecretsNoah Zoschke at Waza 2013: Heroku Secrets
Noah Zoschke at Waza 2013: Heroku Secrets
 
Git Workshop : Git On The Server
Git Workshop : Git On The ServerGit Workshop : Git On The Server
Git Workshop : Git On The Server
 
Inside GitHub with Chris Wanstrath
Inside GitHub with Chris WanstrathInside GitHub with Chris Wanstrath
Inside GitHub with Chris Wanstrath
 
Creating and Deploying Static Sites with Hugo
Creating and Deploying Static Sites with HugoCreating and Deploying Static Sites with Hugo
Creating and Deploying Static Sites with Hugo
 
以 Laravel 經驗開發 Hyperf 應用
以 Laravel 經驗開發 Hyperf 應用以 Laravel 經驗開發 Hyperf 應用
以 Laravel 經驗開發 Hyperf 應用
 
GIT | Distributed Version Control System
GIT | Distributed Version Control SystemGIT | Distributed Version Control System
GIT | Distributed Version Control System
 
2012 coscup - Build your PHP application on Heroku
2012 coscup - Build your PHP application on Heroku2012 coscup - Build your PHP application on Heroku
2012 coscup - Build your PHP application on Heroku
 
Christian Strappazzon - Presentazione Python Milano - Codemotion Milano 2017
Christian Strappazzon - Presentazione Python Milano - Codemotion Milano 2017Christian Strappazzon - Presentazione Python Milano - Codemotion Milano 2017
Christian Strappazzon - Presentazione Python Milano - Codemotion Milano 2017
 
Rugged Driven Development with Gauntlt
Rugged Driven Development with GauntltRugged Driven Development with Gauntlt
Rugged Driven Development with Gauntlt
 

Ähnlich wie GIT, RVM, FIRST HEROKU APP

.Git for WordPress Developers
.Git for WordPress Developers.Git for WordPress Developers
.Git for WordPress Developersmpvanwinkle
 
Hacking on WildFly 9
Hacking on WildFly 9Hacking on WildFly 9
Hacking on WildFly 9JBUG London
 
Git isthenewsexy
Git isthenewsexyGit isthenewsexy
Git isthenewsexyAilsa126
 
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis OverviewLeo Lorieri
 
Docker worshop @Twitter - How to use your own private registry
Docker worshop @Twitter - How to use your own private registryDocker worshop @Twitter - How to use your own private registry
Docker worshop @Twitter - How to use your own private registrydotCloud
 
How to Use Your Own Private Registry
How to Use Your Own Private RegistryHow to Use Your Own Private Registry
How to Use Your Own Private RegistryDocker, Inc.
 
ASP.NET 5 auf Raspberry PI & docker
ASP.NET 5 auf Raspberry PI & dockerASP.NET 5 auf Raspberry PI & docker
ASP.NET 5 auf Raspberry PI & dockerJürgen Gutsch
 
Implementing a Database and API for your Cloud Service
Implementing a Database and API for your Cloud ServiceImplementing a Database and API for your Cloud Service
Implementing a Database and API for your Cloud ServiceVincent Claes
 
Next-Generation Ruby Deployment with Heroku
Next-Generation Ruby Deployment with HerokuNext-Generation Ruby Deployment with Heroku
Next-Generation Ruby Deployment with HerokuAdam Wiggins
 
Open Source Tools for Leveling Up Operations FOSSET 2014
Open Source Tools for Leveling Up Operations FOSSET 2014Open Source Tools for Leveling Up Operations FOSSET 2014
Open Source Tools for Leveling Up Operations FOSSET 2014Mandi Walls
 
Deploying to Ubuntu on Linode
Deploying to Ubuntu on LinodeDeploying to Ubuntu on Linode
Deploying to Ubuntu on LinodeWO Community
 
ブログ執筆を支える技術
ブログ執筆を支える技術ブログ執筆を支える技術
ブログ執筆を支える技術kazuki morita
 
Gitting the Most From Git
Gitting the Most From GitGitting the Most From Git
Gitting the Most From GitChris Miller
 
Ruby プログラマのための Perl ウェブアプリケーション開発入門 (Perl web development guide for Rubyist )
Ruby プログラマのための Perl ウェブアプリケーション開発入門 (Perl web development guide for Rubyist )  Ruby プログラマのための Perl ウェブアプリケーション開発入門 (Perl web development guide for Rubyist )
Ruby プログラマのための Perl ウェブアプリケーション開発入門 (Perl web development guide for Rubyist ) Kensuke Nagae
 
Kubeflow Development Environment
Kubeflow Development EnvironmentKubeflow Development Environment
Kubeflow Development EnvironmentWeiqiang Zhuang
 
Node.js 기반 정적 페이지 블로그 엔진, 하루프레스
Node.js 기반 정적 페이지 블로그 엔진, 하루프레스Node.js 기반 정적 페이지 블로그 엔진, 하루프레스
Node.js 기반 정적 페이지 블로그 엔진, 하루프레스Rhio Kim
 

Ähnlich wie GIT, RVM, FIRST HEROKU APP (20)

.Git for WordPress Developers
.Git for WordPress Developers.Git for WordPress Developers
.Git for WordPress Developers
 
Hacking on WildFly 9
Hacking on WildFly 9Hacking on WildFly 9
Hacking on WildFly 9
 
Git Heaven with Wakanda
Git Heaven with WakandaGit Heaven with Wakanda
Git Heaven with Wakanda
 
Github basics
Github basicsGithub basics
Github basics
 
Git isthenewsexy
Git isthenewsexyGit isthenewsexy
Git isthenewsexy
 
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview
 
Docker worshop @Twitter - How to use your own private registry
Docker worshop @Twitter - How to use your own private registryDocker worshop @Twitter - How to use your own private registry
Docker worshop @Twitter - How to use your own private registry
 
Hacking on WildFly 9
Hacking on WildFly 9Hacking on WildFly 9
Hacking on WildFly 9
 
SydJS.com
SydJS.comSydJS.com
SydJS.com
 
How to Use Your Own Private Registry
How to Use Your Own Private RegistryHow to Use Your Own Private Registry
How to Use Your Own Private Registry
 
ASP.NET 5 auf Raspberry PI & docker
ASP.NET 5 auf Raspberry PI & dockerASP.NET 5 auf Raspberry PI & docker
ASP.NET 5 auf Raspberry PI & docker
 
Implementing a Database and API for your Cloud Service
Implementing a Database and API for your Cloud ServiceImplementing a Database and API for your Cloud Service
Implementing a Database and API for your Cloud Service
 
Next-Generation Ruby Deployment with Heroku
Next-Generation Ruby Deployment with HerokuNext-Generation Ruby Deployment with Heroku
Next-Generation Ruby Deployment with Heroku
 
Open Source Tools for Leveling Up Operations FOSSET 2014
Open Source Tools for Leveling Up Operations FOSSET 2014Open Source Tools for Leveling Up Operations FOSSET 2014
Open Source Tools for Leveling Up Operations FOSSET 2014
 
Deploying to Ubuntu on Linode
Deploying to Ubuntu on LinodeDeploying to Ubuntu on Linode
Deploying to Ubuntu on Linode
 
ブログ執筆を支える技術
ブログ執筆を支える技術ブログ執筆を支える技術
ブログ執筆を支える技術
 
Gitting the Most From Git
Gitting the Most From GitGitting the Most From Git
Gitting the Most From Git
 
Ruby プログラマのための Perl ウェブアプリケーション開発入門 (Perl web development guide for Rubyist )
Ruby プログラマのための Perl ウェブアプリケーション開発入門 (Perl web development guide for Rubyist )  Ruby プログラマのための Perl ウェブアプリケーション開発入門 (Perl web development guide for Rubyist )
Ruby プログラマのための Perl ウェブアプリケーション開発入門 (Perl web development guide for Rubyist )
 
Kubeflow Development Environment
Kubeflow Development EnvironmentKubeflow Development Environment
Kubeflow Development Environment
 
Node.js 기반 정적 페이지 블로그 엔진, 하루프레스
Node.js 기반 정적 페이지 블로그 엔진, 하루프레스Node.js 기반 정적 페이지 블로그 엔진, 하루프레스
Node.js 기반 정적 페이지 블로그 엔진, 하루프레스
 

Kürzlich hochgeladen

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbuapidays
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 

Kürzlich hochgeladen (20)

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 

GIT, RVM, FIRST HEROKU APP

  • 1. LESSON 2 RVM, GIT, RAILS, HEROKU Pavel Tsiukhtsiayeu github.com/paveltyk
  • 2. TODO • Git • Install • Configure • RVM • Install RVM • Install Ruby • Create Gemset • Rails • Install • Generate project • First commit • Start server • Heroku • Install & Configure • Push Rails app to Heroku • Make it WORK • Tips & Tricks
  • 3.
  • 4. Git :: install • $ sudo apt-get install git-core
  • 5. Git :: configure • $ git config --global user.name "PavelT" • $ git config --global user.email paveltyk@gmail.com Where does git store its settings? • /etc/gitconfig (--system) • ~/.gitconfig (--global) • .git/config
  • 6. Git :: configure • $ git config --list • user.name=PavelT • user.email=paveltyk@gmail.com • color.ui=true • push.default=tracking • $ git config user.name • PavelT • At least have this 4
  • 7. Git :: install and configure • Q&A?
  • 8.
  • 9. RVM :: install • $ sudo apt-get install curl • $ curl –L https://get.rvm.io | bash –s stable • For RVM to work properly, you have to set the 'Run command as login shell' checkbox at Edit / Profile Preferences / Title and Commands in Gnome terminal • More details here: https://rvm.io/integration/gnome-terminal
  • 10. RVM :: install Ruby • $ rvm requirements • Requirements for Linux "Ubuntu 12.04.1 LTS” • ……… • Additional Dependencies: • # For Ruby / Ruby HEAD (MRI, Rubinius, & REE), install the following: build-essential openssl libreadline6 • ruby: /usr/bin/apt-get install libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion pkg-config
  • 11. RVM :: install Ruby • $ sudo apt-get install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion pkg-config
  • 12. RVM :: install Ruby • $ rvm list known • # MRI Rubies • [ruby-]1.8.6[-p420] • ... • [ruby-]1.9.3[-p194] • ... • # Jruby • ... • $ rvm install 1.9.3
  • 13. RVM :: gemset • $ rvm use 1.9.3 • $ which ruby • /home/pavelt/.rvm/rubies/ruby-1.9.3-p194/bin/ruby • $ rvm gemset create first-app • $ rvm gemset use first-app • How to easily switch gemsets & Ruby versions [Tips & Tricks]
  • 15.
  • 16. Rails :: install • $ gem install rails • Fetching: i18n-0.6.1.gem (100%) • Fetching: rails-3.2.8.gem (100%) • ... • 29 gems installed • Successfully installed i18n-0.6.1 • ... • Installing ri documentation for i18n-0.6.1.. • Installing RDoc documentation for rack-cache-1.2... • Ri and RDoc are slow [see Tips & Tricks]
  • 17. Rails :: new app • $ rails new first-app • create README.rdoc • create Rakefile • …… • Fetching gem metadata from https://rubygems.org/......... • Using rake (0.9.2.2) • Using i18n (0.6.1) • ….. • Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
  • 18. Rails :: app skeleton (partial) • app/ - core application code (controllers, views, models…) • config/ - application configuration • db/ - DB related files (migrations, seeds, etc) • lib/ - library modules • log/ - application log files • public/ - publicly accessible data • Gemfile - app gem requirements • .gitignore – patterns for files that should be ignored by git
  • 19. Git :: init repo & initial commit • $ cd first-app • $ git init • Initialized empty Git repository in /home/pavelt/projects/first-app/.git/ • $ git commit --allow-empty -m 'Initial commit’ • [master (root-commit) 6f32ce8] Initial commit
  • 20. Git :: add files & commit • $ git status • # On branch master • # Untracked files: • # (use "git add <file>..." to include in what will be committed) • # • # .gitignore • # Gemfile • # Gemfile.lock • ……. • nothing added to commit but untracked files present (use "git add" to track)
  • 21. Git :: add files & commit • $ git add . • git commit - m ’Initial rails project’
  • 22. Rails :: start server • rails s • => Booting WEBrick • => Rails 3.2.8 application starting in development on http://0.0.0.0:3000 • => Call with -d to detach • => Ctrl-C to shutdown server • [2012-09-23 19:46:46] INFO WEBrick 1.3.1 • [2012-09-23 19:46:46] INFO ruby 1.9.2 (2011-07-09) [x86_64-darwin11.2.0] • [2012-09-23 19:46:46] INFO WEBrick::HTTPServer#start: pid=32565 port=3000
  • 24. Rails :: if rails server failed • If failed with: • home/pavelt/.rvm/gems/ruby-1.9.3-p194/gems/execjs- 1.4.0/lib/execjs/runtimes.rb:51:in `autodetect': Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable) • Uncomment therubyracer gem in ./Gemfile • bundle install • git add Gemfile* • git commit -m ‘Added gem therubyracer’
  • 25.
  • 26. Heroku • What is Heroku? • Heroku is a cloud application platform – a new way of building and deploying web apps. (Heroku | About) • Heroku is a cloud platform as a service (PaaS) supporting several programming languages. (Wikipedia) • Heroku = Easy deployment • Heroku = No server managing • Heroku = Scale with 1 command • Heroku = Read-only file system
  • 27. Heroku :: deployment • How to deploy to Heroku? • Simply push to master branch of your Heroku git repo • $ git push heroku master
  • 28. Heroku :: install & configure • $ gem install heroku • Register at Heroku sign up page • https://api.heroku.com/signup • $ heroku login • Enter your Heroku credentials. • Email: paveltyk@gmail.com • Password (typing will be hidden): • Authentication successful. • More info: https://toolbelt.heroku.com
  • 29. Heroku :: first app • $ heroku create pavelt-first-app • Creating pavelt-first-app... done, stack is cedar • http://pavelt-first-app.herokuapp.com/ | git@heroku.com:pavelt- first-app.git • Git remote heroku added • $ git remote -v • heroku git@heroku.com:pavelt-first-app.git (fetch) • heroku git@heroku.com:pavelt-first-app.git (push)
  • 30. Heroku :: first app • Go to http://pavelt-first-app.herokuapp.com
  • 31. Heroku :: first app • $ git push heroku master • The authenticity of host 'heroku.com (50.19.85.156)' can't be established. • RSA key fingerprint is 8b:48:5e:67:0e:c9:16:47:32:f2:87:0c:1f:c8:60:ad. • Are you sure you want to continue connecting (yes/no)? yes • Warning: Permanently added 'heroku.com,50.19.85.156' (RSA) to the list of known hosts. • Permission denied (publickey). • fatal: The remote end hung up unexpectedly
  • 32. Heroku :: first app • $ heroku keys:add • Could not find an existing public key. • Would you like to generate one? [Yn] y • Generating new SSH public key. • Uploading SSH public key /home/pavelt/.ssh/id_rsa.pub... done • $ git push heroku master
  • 33. Heroku :: first app • Counting objects: 73, done. • Compressing objects: 100% (58/58), done. • …. • -----> Heroku receiving push • -----> Ruby/Rails app detected • -----> Installing dependencies using Bundler version 1.2.0 • … • Installing sqlite3 (1.3.6) with native extensions • Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension. • Failed to install gems via Bundler. • Detected sqlite3 gem which is not supported on Heroku. • http://devcenter.heroku.com/articles/how-do-i-use-sqlite3-for-development • Heroku push rejected, failed to compile Ruby/rails app
  • 34. Heroku :: first app • Remove `gem ‘sqlite3’` line from ./Gemfile, update bundle and commit • $ bundle install • git commit -am ‘Removed SQLite3 gem’ • $ git push heroku master • Counting objects: 73, done. • …. • -----> Heroku receiving push • -----> Ruby/Rails app detected • -----> Installing dependencies using Bundler version 1.2.0 • … • Your bundle is complete! It was installed into ./vendor/bundle • … • -----> Writing config/database.yml to read from DATABASE_URL • -----> Preparing app for Rails asset pipeline • -----> Launching... done, v7 • http://pavelt-first-app.herokuapp.com deployed to Heroku
  • 36. Tips & Tricks :: .rvmrc • Automatically change Ruby version and Gemset • ./.rvmrc • rvm use 1.9.3@first-app --create
  • 37. Tips & Tricks :: disable Ri & RDoc • How to disable Ri and Rdoc? • ~/.gemrc • install: --no-ri --no-rdoc • update: --no-ri --no-rdoc
  • 38. Tips & Tricks :: informative prompt • How to make prompt more informative? • ~/.bashrc • export GIT_PS1_SHOWDIRTYSTATE=true • export GIT_PS1_SHOWUNTRACKEDFILES=true • export GIT_PS1_SHOWSTASHSTATE=true • PS1='[$(~/.rvm/bin/rvm-prompt)]u:W[$(__git_ps1 "%s")] '

Hinweis der Redaktion

  1. Очень многое в экосистеме RoR в той или иной степени связанос Git. Следовательно настройку рабочего окружения начнем именно с установки git.
  2. Есть несколько вариантов установки: из исходников, готовые бинарники.Оптимальный для нас вариант - установка через менеджер пакетов: apt-get / aptitudeЭто займет несколько минут. После того как гит установлен, следует его настроить.
  3. Для этого есть утилита gitconfig. Все сделанные далее изменения будут перманентны. Но по желанию их конечно же можно изменить. Первое что следует сделать это указать имя и email. Что мы сейчас и сделаем.Эти переменные очень важны, т.к. во всех Ваших последующих комитах будет записано их значение. Это как Ваша подпись на каждом комите - сказать что это сделали не Вы уже не получится :)Как Вы заметили в предыдущих командах мы использовали ключ --global Это означает что мы делаем изменения на уровне пользователя системы. Настройки git могут храниться в трех местах:1. /etc/gitconfig - конфиг для всех пользователей системы и всех проектов. gitconfig будет писать в этот файл когда передан ключ --system2. ~/.gitconfig - конфиг для текущего пользователя системы. gitconfig будет писать в этот файл когда передан ключ --global3. &lt;PATH_TO_REPO&gt;/.git/config - конфиг текущего репозитория. Ключ не надоЧем ближе файл к репозиторию - тем выше приоритет его переменных. Например, только что мы указали user.name и user.email на уровне --global, т.е. эта подпись комитов будет использоваться во всех репозиториях текущего пользователя. Если в каком-то из проектов Вы захотите использовать другой email для подписи - следует в самом репозитории переопределить это значение (&lt;PATH_TO_REPO&gt;/.git/config).
  4. Проверить значения переменных можно так gitconfig --listОдна и таже переменная может быть выведена несколько раз.Если надо проверить значение конкретной переменной:gitconfiguser.name
  5. Теперь перейдем к установке руби. Для Рельс третьей версии нужен ruby1.8.7 и выше. Я рекомендую ruby 1.9.xRVM - позволяет установить несколько версий руби. Это очень полезно когда у вас есть несколько проектов, тогда для каждого можно настроить свое окружение гемов и разные версии руби.Устанавливать RVM будемтак:
  6. rvm install 1.9.3 - Нас еще раз rvm предупредило о зависимостях (который мы только что установили). Нажимаем &apos;q&apos; чтобы продолжить установку.
  7. В RVM можно для каждой версии руби иметь несколько набровгемов, которые называются gemsetRubyGems это менеджер пакетов для РубиRubyGems разработана для простой уcтановкигемов.  Начиная с Ruby версии 1.9 RubyGems является частью стандартной библиотеки Ruby.Gem - стандартный формат для распространения руби библиотек и программ в автономном форматеОбращаю внимание на то что гемсеты создаются для каждой версии руби отдельно, т.е. у вас не получится использовать один и тот же гемсет в разных версиях руби.
  8. Как видно из лога, гемrails также устанавливает все свои зависимости, генерирует ri и rdoc документацию. Многие программисты (я в том числе) находят временнЫе затраты на генерацию этой документации не стоящими результата и предпочитают использовать online ресурсы. Например http://api.rubyonrails.org
  9. Рельсы установлены. Проверить версию рельс можно так: rails -vСамое время попробовать создать новый проект.Как видно из лога, команда railsnew сгенерировала скелет проекта и установила все необходимые гемы. Скелет проекта это одно из многих преимуществ rails. Одной командой мы только что сгенерировали работающее приложение. А так как структура проекта одинаковая, вы всегда сможете быстро найти интересующий код в чужом проекте.
  10. Давайте рассмотрим структуру приложение на RoR. Я опущу директории/файлы, которые не важны на данный момент:app/ - основной код приложения. Здесь находятся модели, вьюхи, контроллеры и хелперы.config/ - конфигурация и инициализация проекта здесьdb/ - здесь хранятся файлы связанные с базой данных (миграции, сиды, файлы файл ориентированных БД)lib/ - сюда принято помещать модули и классы напрямую не связанные с вашим проектомlog/ - сюда рельсы будут записывать свои логиpublic/ - все файлы в этой папке будут доступны пользователям/браузеруGemfile - здесь описаны все гемы от которых зависит проект.gitignore - описаны паттерны файлов которые git должен игнорировать
  11. Пока мы ничего не поломали - самое время сделать комит. Первое что нам надо сделать это инициализировать gitрепозиторий. Делается это командой:gitinit
  12. Посмотрим что у нас с деревомКак видно все файлы unstaged.
  13. Добавим все файлы проекта (за исключением тех что попадают под описание .gitignore) в stagingarea.
  14. Запускаем локальный сервер. смотрим браузер
  15. Если сервер не запустится с такой ошибкой, отредактировать Gemfile.
  16. УжесейчасможнопопробоватьзадеплоитьприложениенаХероку
  17. Что такое Хероку?!Хероку себя определяет как облачная платформа приложений - новый способ создания и развертывания приложений.Википедия говорит что Хероку это облачная платформа как сервис, с поддержкой нескольких языков программирования.Для меня Хероку это найпростейшийдеплоймент, отсутствие необходимости управлять серверами, масштабирование одной командой.
  18. Так как же деплоить на Хероку? Просто запушить код в репозиторий вашего приложения на Хероку. Afterpushколбэки настроят окружение, скомпилируют ассеты, запустят инстансы только что задеплоеного приложения.
  19. У Хероку есть очень удобный CLI который устанавливается вместе с гемомheroku. Прямо сейчас мы его и установим: