rename foreign uuid attributes
[arvados.git] / doc / install / install-api-server.md
1 ---
2 layout: default
3 navsection: installguide
4 title: Install the API server
5 navorder: 1
6 ---
7
8 {% include alert-stub.html %}
9
10 # API server setup
11
12 ## Prerequisites
13
14 1. A GNU/linux (virtual) machine
15 2. A domain name for your api server
16
17 ## Download the source tree
18
19 Please follow the instructions on the [Download page](https://arvados.org/projects/arvados/wiki/Download) in the wiki.
20
21 ## Configure the API server
22
23 First configure the database:
24
25     cp config/database.yml.sample config/database.yml
26
27 Edit database.yml to your liking and make sure the database and db user exist.
28 Then set up the database:
29  
30     RAILS_ENV=production rake db:setup
31
32 Then set up omniauth:
33
34     cp config/initializers/omniauth.rb.example config/initializers/omniauth.rb
35
36 Edit config/initializers/omniauth.rb. Choose an *APP_SECRET* and *APP_ID*. Also set
37 *CUSTOM_PROVIDER_URL*.
38
39 Make sure your Omniauth provider knows about your *APP_ID* and *APP_SECRET*
40 combination.
41
42 You also need to update config/initializers/secret_token.rb. Generate a new secret with
43
44     rake secret
45
46 and put it in config/initializers/secret_token.rb:
47
48     Server::Application.config.secret_token = 'your-new-secret-here'
49
50 Finally, edit your
51
52     environments/production.rb
53
54 file. 
55
56 First, you want to make sure that 
57
58     config.uuid_prefix
59
60 is set to a unique 5-digit hex string. You can replace the 'cfi-aws-0' string
61 with a string of your choice to make that happen.
62
63 The *config.uuid_prefix* string is a unique identifier for your API server. It
64 also serves as the first part of the hostname for your API server, for instance
65
66     {{ site.arvados_api_host }}
67
68 You should use your own domain instead of arvadosapi.com
69
70 Second, unless you are running on AWS, you will want to change the definition of
71
72     config.compute_node_nameservers
73
74 If you know your nameservers and they are fixed, you can hardcode them, and
75 make sure to remove the code that tries to look them up from the AWS metadata:
76
77     config.compute_node_nameservers = ['1.2.3.4','2.3.4.5','3.4.5.6']
78     #require 'net/http'
79     #config.compute_node_nameservers = ['local', 'public'].collect do |iface|
80     #  Net::HTTP.get(URI("http://169.254.169.254/latest/meta-data/#{iface}-ipv4")).match(/^[\d\.]+$/)[0]
81     #end << '172.16.0.23'
82
83 ## Apache/Passenger
84
85 Set up Apache and Passenger. Point them to the services/api directory in the source tree.
86
87 To enable streaming so users can monitor crunch jobs in real time, add
88 to your Apache configuration:
89
90     PassengerBufferResponse off
91
92 ## Add an admin user
93
94 Point browser to the API endpoint. Log in with a google account.
95
96 In the rails console:
97
98     Thread.current[:user] = User.find(1)
99     Thread.current[:user].is_admin = true
100     User.find(1).update_attributes is_admin: true, is_active: true
101     User.find(1).is_admin
102
103 This should be
104
105      => true
106
107 ## Create a token
108
109 In rails console
110
111      a = ApiClient.new(owner_uuid:'0'); a.save!
112      x = ApiClientAuthorization.new(api_client_id:a.id, user_id:1); x.save; x.api_token
113