Merge branch 'master' of git.curoverse.com:arvados into 3408-production-datamanager
[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: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 # Configure Apache and Passenger.
48 RUN a2dissite default && \
49     a2ensite arvados && \
50     a2enmod rewrite && \
51     a2enmod ssl && \
52     /bin/mkdir /var/run/apache2
53
54 # Install a token for root
55 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
56
57 # Set up directory for job commit repo
58 RUN mkdir -p /var/lib/arvados
59 # Add crunch user
60 RUN addgroup --gid 4005 crunch && mkdir /home/crunch && useradd --uid 4005 --gid 4005 crunch && chown crunch:crunch /home/crunch
61
62 # Create keep and compute node objects
63 ADD keep_server_0.json /root/
64 ADD keep_server_1.json /root/
65
66 # Set up update-gitolite.rb
67 RUN mkdir /usr/local/arvados/config -p
68 ADD generated/arvados-clients.yml /usr/local/arvados/config/
69 ADD update-gitolite.rb /usr/local/arvados/
70
71 # Supervisor.
72 ADD supervisor.conf /etc/supervisor/conf.d/arvados.conf
73 ADD ssh.sh /usr/local/bin/ssh.sh
74 ADD generated/setup.sh /usr/local/bin/setup.sh
75 ADD generated/setup-gitolite.sh /usr/local/bin/setup-gitolite.sh
76 ADD crunch-dispatch-run.sh /usr/local/bin/crunch-dispatch-run.sh
77 ADD apache2_foreground.sh /etc/apache2/foreground.sh
78
79 # Start the supervisor.
80 CMD ["/usr/bin/supervisord", "-n"]