Merge branch 'master' into 2257-inequality-conditions
[arvados.git] / doc / install / install-api-server.html.textile.liquid
1 ---
2 layout: default
3 navsection: installguide
4 title: Install the API server
5 ...
6
7 h2. Prerequisites:
8
9 # A GNU/Linux (virtual) machine
10 # A domain name for your api server
11 # Ruby >= 2.0.0
12 # Bundler: @gem install bundler@
13 # Curl libraries: @sudo apt-get install libcurl3 libcurl3-gnutls libcurl4-openssl-dev@
14
15 h2. Download the source tree
16
17 <notextile>
18 <pre><code>~$ <span class="userinput">git clone https://github.com/curoverse/arvados.git</span>
19 </code></pre></notextile>
20
21 See also: "Downloading the source code:https://arvados.org/projects/arvados/wiki/Download on the Arvados wiki.
22
23 h2. Install gem dependencies
24
25 <notextile>
26 <pre><code>~$ <span class="userinput">cd arvados/services/api</span>
27 ~/arvados/services/api$ <span class="userinput">bundle install</span>
28 </code></pre></notextile>
29
30 h2. Configure the API server
31
32 Edit the main configuration:
33
34 <notextile>
35 <pre><code>~/arvados/services/api$ <span class="userinput">cp -i config/application.yml.example config/application.yml</span>
36 </code></pre></notextile>
37
38 Choose a unique 5-character alphanumeric string to use as your @uuid_prefix@. An example is given that generates a 5-character string based on a hash of your hostname. The @uuid_prefix@ is a unique identifier for your API server. It also serves as the first part of the hostname for your API server.
39
40 For a development site, use your own domain instead of arvadosapi.com.
41
42 Make sure a clone of the arvados repository exists in @git_repositories_dir@:
43
44 <notextile>
45 <pre><code>~/arvados/services/api$ <span class="userinput">sudo mkdir -p /var/cache/git</span>
46 ~/arvados/services/api$ <span class="userinput">sudo git clone --bare ../../.git /var/cache/git/arvados.git</span>
47 </code></pre></notextile>
48
49 Generate a new secret token for signing cookies:
50
51 <notextile>
52 <pre><code>~/arvados/services/api$ <span class="userinput">rake secret
53 zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
54 </code></pre></notextile>
55
56 Put it in @config/application.yml@ in the production or common section:
57
58 <notextile>
59 <pre><code><span class="userinput">    secret_token: zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz</span>
60 </code></pre>
61 </notextile>
62
63 Consult @application.default.yml@ for a full list of configuration options. Always put your local configuration in @application.yml@ instead of editing @application.default.yml@.
64
65 Configure the database:
66
67 <notextile>
68 <pre><code>~/arvados/services/api$ <span class="userinput">cp -i config/database.yml.sample config/database.yml</span>
69 </code></pre></notextile>
70
71 By default, the development database will use the sqlite3 driver, so no configuration is necessary.  If you wish to use mysql or postgres, edit @config/database.yml@ to your liking and make sure the database and db user exist. Then initialize the database:
72
73 <notextile>
74 <pre><code>~/arvados/services/api$ <span class="userinput">RAILS_ENV=development bundle exec rake db:setup</span>
75 </code></pre></notextile>
76
77 Set up omniauth:
78
79 <notextile>
80 <pre><code>~/arvados/services/api$ <span class="userinput">cp -i config/initializers/omniauth.rb.example config/initializers/omniauth.rb
81 </code></pre></notextile>
82
83 Edit @config/initializers/omniauth.rb@. Set @APP_SECRET@ to the value of @app_secret@ from "installing the single sign on server":install-sso.html .
84
85 You can now run the development server:
86
87 <notextile>
88 <pre><code>~/arvados/services/api$ <span class="userinput">rails server
89 </code></pre></notextile>
90
91 h3. Apache/Passenger (optional)
92
93 You can use "Passenger":https://www.phusionpassenger.com/ for deployment. Point it to the services/api directory in the source tree.
94
95 To enable streaming so users can monitor crunch jobs in real time, add to your Passenger configuration in Apache:
96
97 <notextile>
98 <pre><code><span class="userinput">PassengerBufferResponse off</span>
99 </code></pre>
100 </notextile>
101
102 h2. Add an admin user
103
104 Point browser to the API endpoint. Log in with a google account.
105
106 In the rails console:
107
108 <notextile>
109 <pre><code>~/arvados/services/api$ <span class="userinput">rails console</span>
110 irb(main):001:0&gt; <span class="userinput">Thread.current[:user] = User.find(1)</span>
111 irb(main):002:0&gt; <span class="userinput">Thread.current[:user].is_admin = true</span>
112 irb(main):003:0&gt; <span class="userinput">User.find(1).update_attributes is_admin: true, is_active: true</span>
113 irb(main):004:0&gt; <span class="userinput">User.find(1).is_admin</span>
114 =&gt; true
115 </code></pre></notextile>
116
117 h2. Create an API token
118
119 In rails console:
120
121 <notextile>
122 <pre><code>~/arvados/services/api$ <span class="userinput">rails console</span>
123 irb(main):001:0&gt; <span class="userinput">a = ApiClient.new(owner_uuid:'0')</span>
124 irb(main):002:0&gt; <span class="userinput">a.save!</span>
125 irb(main):003:0&gt; <span class="userinput">x = ApiClientAuthorization.new(api_client_id:a.id, user_id:1)</span>
126 irb(main):004:0&gt; <span class="userinput">x.save</span>
127 irb(main):005:0&gt; <span class="userinput">x.api_token</span>
128 </code></pre></notextile>