e5bd5c82bc9fc183ef5836dc83805c38a650feaa
[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 Configure the database:
33
34 <notextile>
35 <pre><code>~/arvados/services/api$ <span class="userinput">cp -i config/database.yml.sample config/database.yml</span>
36 </code></pre></notextile>
37
38 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:
39
40 <notextile>
41 <pre><code>~/arvados/services/api$ <span class="userinput">RAILS_ENV=development bundle exec rake db:setup</span>
42 </code></pre></notextile>
43
44 Then set up omniauth:
45
46 <notextile>
47 <pre><code>~/arvados/services/api$ <span class="userinput">cp -i config/initializers/omniauth.rb.example config/initializers/omniauth.rb
48 </code></pre></notextile>
49
50 Edit @config/initializers/omniauth.rb@. Set @APP_SECRET@ to the value of @app_secret@ from "installing the single sign on server":install-sso.html .
51
52 Next, edit the main configuration:
53
54 <notextile>
55 <pre><code>~/arvados/services/api$ <span class="userinput">cp -i config/application.yml.example config/application.yml
56 </code></pre></notextile>
57
58 First, 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.
59
60 For a development site, use your own domain instead of arvadosapi.com.
61
62 You also need to install a secret_token for signing cookies. Generate a new secret:
63
64 <notextile>
65 <pre><code>~/arvados/services/api$ <span class="userinput">rake secret
66 zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
67 </code></pre></notextile>
68
69 Put it in @config/application.yml@ in the production or common section:
70
71 <notextile>
72 <pre><code><span class="userinput">    secret_token: zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz</span>
73 </code></pre>
74 </notextile>
75
76 You will also want to change @compute_node_nameservers@ to suit your environment.
77
78 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@.
79
80 You can now run the development server:
81
82 <notextile>
83 <pre><code>~/arvados/services/api$ <span class="userinput">rails server
84 </code></pre></notextile>
85
86 h3. Apache/Passenger (optional)
87
88 You can use "Passenger":https://www.phusionpassenger.com/ for deployment. Point it to the services/api directory in the source tree.
89
90 To enable streaming so users can monitor crunch jobs in real time, add to your Passenger configuration in Apache:
91
92 <notextile>
93 <pre><code><span class="userinput">PassengerBufferResponse off</span>
94 </code></pre>
95 </notextile>
96
97 h2. Add an admin user
98
99 Point browser to the API endpoint. Log in with a google account.
100
101 In the rails console:
102
103 <notextile>
104 <pre><code>~/arvados/services/api$ <span class="userinput">rails console</span>
105 irb(main):001:0&gt; <span class="userinput">Thread.current[:user] = User.find(1)</span>
106 irb(main):002:0&gt; <span class="userinput">Thread.current[:user].is_admin = true</span>
107 irb(main):003:0&gt; <span class="userinput">User.find(1).update_attributes is_admin: true, is_active: true</span>
108 irb(main):004:0&gt; <span class="userinput">User.find(1).is_admin</span>
109 =&gt; true
110 </code></pre></notextile>
111
112 h2. Create an API token
113
114 In rails console:
115
116 <notextile>
117 <pre><code>~/arvados/services/api$ <span class="userinput">rails console</span>
118 irb(main):001:0&gt; <span class="userinput">a = ApiClient.new(owner_uuid:'0')</span>
119 irb(main):002:0&gt; <span class="userinput">a.save!</span>
120 irb(main):003:0&gt; <span class="userinput">x = ApiClientAuthorization.new(api_client_id:a.id, user_id:1)</span>
121 irb(main):004:0&gt; <span class="userinput">x.save</span>
122 irb(main):005:0&gt; <span class="userinput">x.api_token</span>
123 </code></pre></notextile>