4752: Use passenger standalone for API server instead of passenger apache module...
[arvados.git] / docker / api / Dockerfile
1 # Arvados API server Docker container.
2
3 FROM arvados/passenger
4 MAINTAINER Ward Vandewege <ward@curoverse.com>
5
6 # Install postgres and apache.
7 RUN apt-get update -qq
8 RUN apt-get install -qqy \
9     procps postgresql postgresql-server-dev-9.1 slurm-llnl munge \
10     supervisor sudo libwww-perl libio-socket-ssl-perl libcrypt-ssleay-perl \
11     libjson-perl cron openssh-server
12
13 ADD munge.key /etc/munge/
14 RUN chown munge:munge /etc/munge/munge.key && chmod 600 /etc/munge/munge.key
15 ADD generated/slurm.conf /etc/slurm-llnl/
16
17 RUN /usr/local/rvm/bin/rvm-exec default gem install arvados-cli arvados
18 # /for crunch-dispatch
19
20 RUN /bin/mkdir -p /usr/src/arvados/services
21 ADD generated/api.tar.gz /usr/src/arvados/services/
22
23 # Install generated config files
24 ADD generated/database.yml /usr/src/arvados/services/api/config/database.yml
25 ADD generated/omniauth.rb /usr/src/arvados/services/api/config/initializers/omniauth.rb
26 RUN /bin/cp /usr/src/arvados/services/api/config/environments/production.rb.example /usr/src/arvados/services/api/config/environments/production.rb
27 ADD generated/application.yml /usr/src/arvados/services/api/config/application.yml
28
29 # Configure Rails databases.
30 ENV RAILS_ENV production
31 ADD generated/config_databases.sh /tmp/config_databases.sh
32 ADD generated/superuser_token /tmp/superuser_token
33 RUN /usr/local/rvm/bin/rvm-exec default bundle install --gemfile=/usr/src/arvados/services/api/Gemfile && \
34     sh /tmp/config_databases.sh && \
35     rm /tmp/config_databases.sh && \
36     /etc/init.d/postgresql start && \
37     cd /usr/src/arvados/services/api && \
38     /usr/local/rvm/bin/rvm-exec default bundle exec rake db:structure:load && \
39     /usr/local/rvm/bin/rvm-exec default bundle exec rake db:seed && \
40     /usr/local/rvm/bin/rvm-exec default bundle exec rake assets:precompile && \
41     /usr/local/rvm/bin/rvm-exec default ./script/create_superuser_token.rb $(cat /tmp/superuser_token) && \
42     chown www-data:www-data config.ru && \
43     chown www-data:www-data log -R && \
44     mkdir -p tmp && \
45     chown www-data:www-data tmp -R
46
47 # Install a token for root
48 RUN mkdir -p /root/.config/arvados; echo "ARVADOS_API_HOST=api" >> /root/.config/arvados/settings.conf && echo "ARVADOS_API_HOST_INSECURE=yes" >> /root/.config/arvados/settings.conf && echo "ARVADOS_API_TOKEN=$(cat /tmp/superuser_token)" >> /root/.config/arvados/settings.conf && chmod 600 /root/.config/arvados/settings.conf
49
50 # Set up directory for job commit repo
51 RUN mkdir -p /var/lib/arvados
52 # Add crunch user
53 RUN addgroup --gid 4005 crunch && mkdir /home/crunch && useradd --uid 4005 --gid 4005 crunch && chown crunch:crunch /home/crunch
54
55 # Create keep and compute node objects
56 ADD keep_server_0.json /root/
57 ADD keep_server_1.json /root/
58 ADD keep_proxy.json /root/
59
60 # Set up update-gitolite.rb
61 RUN mkdir /usr/local/arvados/config -p
62 ADD generated/arvados-clients.yml /usr/local/arvados/config/
63 ADD update-gitolite.rb /usr/local/arvados/
64
65 # Supervisor.
66 ADD supervisor.conf /etc/supervisor/conf.d/arvados.conf
67 ADD generated/setup.sh /usr/local/bin/setup.sh
68 ADD generated/setup-gitolite.sh /usr/local/bin/setup-gitolite.sh
69 ADD crunch-dispatch-run.sh /usr/local/bin/crunch-dispatch-run.sh
70 ADD munge.sh /usr/local/bin/munge.sh
71 ADD passenger.sh /usr/local/bin/passenger.sh
72
73 # Start the supervisor.
74 CMD ["/usr/bin/supervisord", "-n"]