3349: Merge branch 'master' into 3349-install-docs
[arvados.git] / docker / api / Dockerfile
1 # Arvados API server Docker container.
2
3 FROM arvados/passenger
4 MAINTAINER Tim Pierce <twp@curoverse.com>
5
6 # Install postgres and apache.
7 RUN apt-get update && \
8     apt-get -q -y install procps postgresql postgresql-server-dev-9.1 apache2 slurm-llnl munge \
9                           supervisor sudo libwww-perl libio-socket-ssl-perl libcrypt-ssleay-perl \
10                           libjson-perl cron
11
12 ADD munge.key /etc/munge/
13 RUN chown munge:munge /etc/munge/munge.key && chmod 600 /etc/munge/munge.key
14 ADD generated/slurm.conf /etc/slurm-llnl/
15
16 RUN /usr/local/rvm/bin/rvm-exec default gem install arvados-cli arvados
17 # /for crunch-dispatch
18
19 RUN /bin/mkdir -p /usr/src/arvados/services
20 ADD generated/api.tar.gz /usr/src/arvados/services/
21
22 # Install generated config files
23 ADD generated/database.yml /usr/src/arvados/services/api/config/database.yml
24 ADD generated/omniauth.rb /usr/src/arvados/services/api/config/initializers/omniauth.rb
25 RUN /bin/cp /usr/src/arvados/services/api/config/environments/production.rb.example /usr/src/arvados/services/api/config/environments/production.rb
26 ADD generated/application.yml /usr/src/arvados/services/api/config/application.yml
27 ADD generated/apache2_vhost /etc/apache2/sites-available/arvados
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:setup && \
39     /usr/local/rvm/bin/rvm-exec default bundle exec rake assets:precompile && \
40     /usr/local/rvm/bin/rvm-exec default ./script/create_superuser_token.rb $(cat /tmp/superuser_token) && \
41     chown www-data:www-data config.ru && \
42     chown www-data:www-data log -R && \
43     mkdir -p tmp && \
44     chown www-data:www-data tmp -R
45
46 # Configure Apache and Passenger.
47 RUN a2dissite default && \
48     a2ensite arvados && \
49     a2enmod rewrite && \
50     a2enmod ssl && \
51     /bin/mkdir /var/run/apache2
52
53 # Install a token for root
54 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
55
56 # Set up directory for job commit repo
57 RUN mkdir -p /var/lib/arvados
58 # Add crunch user
59 RUN addgroup --gid 4005 crunch && mkdir /home/crunch && useradd --uid 4005 --gid 4005 crunch && chown crunch:crunch /home/crunch
60
61 # Create keep and compute node objects
62 ADD keep_server_0.json /root/
63 ADD keep_server_1.json /root/
64
65 # Set up update-gitolite.rb
66 RUN mkdir /usr/local/arvados/config -p
67 ADD generated/arvados-clients.yml /usr/local/arvados/config/
68 ADD update-gitolite.rb /usr/local/arvados/
69
70 # Supervisor.
71 ADD supervisor.conf /etc/supervisor/conf.d/arvados.conf
72 ADD ssh.sh /usr/local/bin/ssh.sh
73 ADD generated/setup.sh /usr/local/bin/setup.sh
74 ADD generated/setup-gitolite.sh /usr/local/bin/setup-gitolite.sh
75 ADD crunch-dispatch-run.sh /usr/local/bin/crunch-dispatch-run.sh
76 ADD apache2_foreground.sh /etc/apache2/foreground.sh
77
78 # Start the supervisor.
79 CMD ["/usr/bin/supervisord", "-n"]