container is launched.
Move generated files to an api/generated directory for
easier ignoring.
*~
*.pyc
+docker/api/generated/*
\ No newline at end of file
# Install postgres and apache
RUN apt-get -q -y install procps postgresql postgresql-server-dev-9.1 apache2 \
- libcurl4-openssl-dev apache2-threaded-dev libapr1-dev libaprutil1-dev
-
-# Configure databases and users.
-ADD config_databases.sh /tmp/
-RUN sh /tmp/config_databases.sh
-RUN rm /tmp/config_databases.sh
+ libcurl4-openssl-dev apache2-threaded-dev libapr1-dev libaprutil1-dev \
+ supervisor
# Install gems needed for API server
RUN bundle install --gemfile=/usr/src/arvados/services/api/Gemfile
+# Install generated config files
+ADD generated/database.yml /usr/src/arvados/services/api/config/database.yml
+ADD generated/secret_token.rb /usr/src/arvados/services/api/config/initializers/secret_token.rb
+ADD generated/omniauth.rb /usr/src/arvados/services/api/config/initializers/omniauth.rb
+ADD generated/production.rb /usr/src/arvados/services/api/config/environments/production.rb
+
+# Configure databases and users.
+ADD generated/config_databases.sh /tmp/config_databases.sh
+RUN sh /tmp/config_databases.sh ; \
+ rm /tmp/config_databases.sh
+
# Set up the Rails database. This has to be done in a script so that
# postgres can run in the background while running rake db:setup.
ENV RAILS_ENV production
-ADD database.yml /usr/src/arvados/services/api/config/database.yml
ADD config_rake.sh /tmp/config_rake.sh
-RUN sh /tmp/config_rake.sh
+RUN sh /tmp/config_rake.sh ; \
+ rm /tmp/config_rake.sh
-ADD secret_token.rb /usr/src/arvados/services/api/config/initializers/secret_token.rb
-ADD omniauth.rb /usr/src/arvados/services/api/config/initializers/omniauth.rb
-ADD production.rb /usr/src/arvados/services/api/config/environments/production.rb
-
-# Configure Apache.
+# Configure Apache and Passenger.
ADD apache2_vhost /etc/apache2/sites-available/arvados
-RUN a2dissite default
-RUN a2ensite arvados
-
-# Configure Passenger.
-RUN passenger-install-apache2-module --auto
-RUN a2enmod rewrite
ADD passenger.conf /etc/apache2/conf.d/passenger
+RUN a2dissite default ; \
+ a2ensite arvados ; \
+ a2enmod rewrite ; \
+ passenger-install-apache2-module --auto
+
+# Supervisor.
+ADD supervisor.conf /etc/supervisor/conf.d/arvados.conf
+ADD apache2_foreground.sh /etc/apache2/foreground.sh
+
+# Start the supervisor.
+CMD ["/usr/bin/supervisord", "-n"]
FROM arvados/debian:wheezy
MAINTAINER Tim Pierce <twp@clinicalfuture.com>
-# TODO(twp): parameterize variables via autoconf or similar.
-ENV RUBY_VERSION_NUM 2.0.0
-
# Install prerequisite packages for Arvados
-RUN apt-get update
-RUN apt-get -q -y install -q -y apt-utils
-RUN apt-get -q -y install git curl
-RUN curl -L https://get.rvm.io | bash -s stable --ruby=${RUBY_VERSION_NUM}
+# * git, curl, rvm
+# * Arvados source code
+#
+RUN apt-get update && \
+ apt-get -q -y install -q -y apt-utils && \
+ apt-get -q -y install git curl && \
+ git clone git://github.com/clinicalfuture/arvados.git /usr/src/arvados && \
+ curl -L https://get.rvm.io | bash -s stable --ruby=2.0.0
# Set up RVM environment. These are just the env variables created by
# /usr/local/rvm/scripts/rvm, which can't be run from a non-login shell.
# TODO(twp): figure out a less awful solution.
-ENV RUBY_VERSION ruby-2.0.0-p247
-ENV MY_RUBY_HOME /usr/local/rvm/rubies/ruby-2.0.0-p247
ENV GEM_HOME /usr/local/rvm/gems/ruby-2.0.0-p247
ENV GEM_PATH /usr/local/rvm/gems/ruby-2.0.0-p247:/usr/local/rvm/gems/ruby-2.0.0-p247@global
-ENV IRBRC /usr/local/rvm/rubies/ruby-2.0.0-p247/.irbrc
-ENV rvm_path /usr/local/rvm
-ENV rvm_prefix /usr/local
-ENV rvm_env_string ruby-2.0.0-p247
-ENV rvm_version 1.23.13 (stable)
-ENV rvm_ruby_string ruby-2.0.0-p247
ENV PATH /usr/local/rvm/gems/ruby-2.0.0-p247/bin:/usr/local/rvm/gems/ruby-2.0.0-p247@global/bin:/usr/local/rvm/rubies/ruby-2.0.0-p247/bin:/usr/local/rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
-
-# Download Arvados source.
-RUN git clone git://github.com/clinicalfuture/arvados.git /usr/src/arvados
-
./mkimage-debootstrap.sh arvados/debian wheezy http://debian.lcs.mit.edu/debian/
# build the Docker images
-docker build -rm -t arvados/base base
-docker build -rm -t arvados/api api
+docker build -t arvados/base base
+docker build -t arvados/api api
# For each *.in file in the docker directories, substitute any
# @@variables@@ found in the file with the appropriate config
# variable.
+#
+# TODO(twp): add the *.in files directory to the source tree, and
+# when expanding them, add them to the "generated" directory with
+# the same tree structure as in the original source. Then all
+# the files can be added to the docker container with a single ADD.
Dir.glob('*/*.in') do |template_file|
- output_path = template_file.sub(/\.in$/, '')
+ generated_dir = File.join(File.dirname(template_file), 'generated')
+ Dir.mkdir(generated_dir) unless Dir.exists? generated_dir
+ output_path = File.join(generated_dir, File.basename(template_file, '.in'))
output = File.open(output_path, "w")
File.open(template_file) do |input|
input.each_line do |line|