[Gandi] [Simple Hosting] Application Ruby : Site web

[Gandi] [Simple Hosting] Application Ruby : Site web.

Distribution de travail : Ubuntu 16.04.3 LTS
Hébergement : Instance Simple Hosting de type ‘Ruby

1/ Sur l’ordinateur de développement, installation du paquet Ruby.

admin@serverbb:~$ sudo apt-get install ruby-full
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
...
Setting up ruby-dev:amd64 (1:2.3.0+1) ...
Setting up ruby-full (1:2.3.0+1) ...
Processing triggers for libc-bin (2.23-0ubuntu9) ...
Processing triggers for systemd (229-4ubuntu19) ...
Processing triggers for ureadahead (0.100.0-19) ...
admin@serverbb:~$

2/ Vérification de la version de Ruby.

admin@serverbb:~$ ruby --version
ruby 2.3.1p112 (2016-04-26) [x86_64-linux-gnu]

3/ Installation de ‘bundler‘.

admin@serverbb:~$ sudo gem install bundler

4/ Répertoire de travail.

admin@serverbb:~$ mkdir -p RUBY/exemple01
admin@serverbb:~$ cd RUBY/exemple01/
admin@serverbb:~/RUBY/exemple01$

5/ Initialisation du squelette du site.

admin@serverbb:~/RUBY/exemple01$ mkdir -p site/public/{images,js,css}
admin@serverbb:~/RUBY/exemple01$ touch site/{config.ru,public/index.html}
admin@serverbb:~/RUBY/exemple01$ cd site/
admin@serverbb:~/RUBY/exemple01/site$

6/ Initialisation de ‘bundler‘.

admin@serverbb:~/RUBY/exemple01/site$ bundle init
Writing new Gemfile to /home/admin/RUBY/exemple01/site/Gemfile
admin@serverbb:~/RUBY/exemple01/site$

7/ Vérification de la structure du site.

admin@serverbb:~/RUBY/exemple01/site$ tree
.
|-- Gemfile
|-- config.ru
`-- public
    |-- css
    |-- images
    |-- index.html
    `-- js
4 directories, 3 files
admin@serverbb:~/RUBY/exemple01/site$

8/ Ajout du gem ‘rack‘.

Ouvrir :

Gemfile

Ajouter à la fin :

gem 'rack'

9/ Installation du gem ‘rack‘.

admin@serverbb:~/RUBY/exemple01/site$ bundle install
Fetching gem metadata from https://rubygems.org/..............
Fetching version metadata from https://rubygems.org/.
Resolving dependencies...
Using bundler 1.15.4
Fetching rack 2.0.3
...
Installing rack 2.0.3
Bundle complete! 1 Gemfile dependency, 2 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
admin@serverbb:~/RUBY/exemple01/site$

10/ Configuration de ‘rack‘.

Ouvrir :

config.ru

Ajouter :

use Rack::Static,
  :urls => ["/images", "/js", "/css"],
  :root => "public"
run lambda { |env|
  [
    200,
    {
      'Content-Type'  => 'text/html',
      'Cache-Control' => 'public, max-age=86400'
    },
    File.open('public/index.html', File::RDONLY)
  ]
}

11/ Modification de la page d’accueil.

Ouvrir :

public/index.html

Ajouter :

 < html>
   < head>
   < head>
   < body>
     Ruby \m/
    < /body>
  < /html>

12/ Versionning du projet.

– Ajout de tous les fichiers :

admin@serverbb:~/RUBY/exemple01/site$ git add -A

– Commit :

admin@serverbb:~/RUBY/exemple01/site$ git commit -m "Version 0.0.1"
[master (root-commit) efbacae] Version 0.0.1
 4 files changed, 34 insertions(+)
 create mode 100644 Gemfile
 create mode 100644 Gemfile.lock
 create mode 100644 config.ru
 create mode 100644 public/index.html
admin@serverbb:~/RUBY/exemple01/site$

– Ajout de la branche distante Gandi :

admin@serverbb:~/RUBY/exemple01/site$ git remote add gandi git+ssh://1951612@git.dc2.gpaas.net/default.git

– Pousser le commit vers la branche distante :

admin@serverbb:~/RUBY/exemple01/site$ git push gandi master
1951612@git.dc2.gpaas.net's password:
Counting objects: 7, done.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (7/7), 828 bytes | 0 bytes/s, done.
Total 7 (delta 0), reused 0 (delta 0)
To git+ssh://1951612@git.dc2.gpaas.net/default.git
 * [new branch]      master -> master
admin@serverbb:~/RUBY/exemple01/site$

– Déploiement de l’application :

admin@serverbb:~/RUBY/exemple01/site$ ssh 1951612@git.dc2.gpaas.net 'deploy default.git'
1951612@git.dc2.gpaas.net's password:
initializing builder
...........................builder ready
Vm password:
Grabbing terminal
Ok
-----> Starting new deployment (default - master)
-----> Fetching application code
-----> Building new application
Warning: the running version of Bundler (1.15.3) is older than the version that created the lockfile (1.15.4). We suggest you upgrade to the latest version of Bundler by running `gem install bundler`.
Fetching gem metadata from https://rubygems.org/..............
Fetching version metadata from https://rubygems.org/.
Using bundler 1.15.3
Fetching rack 2.0.3
Installing rack 2.0.3
Bundle complete! 1 Gemfile dependency, 2 gems now installed.
Gems in the groups development and test were not installed.
Bundled gems are installed into ./vendor/bundle.
-----> Copying new application
sending incremental file list
bundle/
...
total size is 1,081,797  speedup is 0.98
sending incremental file list
Gemfile
Gemfile.lock
config.ru
.bundle/
.bundle/config
public/
public/index.html
sent 1,149 bytes  received 128 bytes  2,554.00 bytes/sec
total size is 668  speedup is 0.52
-----> Build complete
-----> Cleaning temporary files
admin@serverbb:~/RUBY/exemple01/site$

13/ Visualisation de la page.

http://ae87038bb9.testurl.ws/

14/ Liens.

https://wiki.gandi.net/fr/simple/git
https://wiki.gandi.net/fr/simple/instance/ruby

Comments are closed, but trackbacks and pingbacks are open.