Merging the postgres container back into the api container (simpler
authorTim Pierce <twp@clinicalfuture.com>
Wed, 6 Nov 2013 23:11:51 +0000 (18:11 -0500)
committerTim Pierce <twp@clinicalfuture.com>
Wed, 6 Nov 2013 23:11:51 +0000 (18:11 -0500)
and more consistent with best practices).

'docker build -t arvados/api api' now builds a container with postgres
and apache2, and installs the API Rails database.

To have this container start multiple services at run time
(i.e. postgres + apache2) the popular solution is to make supervisord
the entrypoint for the container.

docker/api/Dockerfile [new file with mode: 0644]
docker/api/config_rake.sh [changed mode: 0644->0755]
docker/api/postgresql_config.sh [moved from docker/postgresql/postgresql_config.sh with 100% similarity]
docker/base/Dockerfile
docker/build.sh

diff --git a/docker/api/Dockerfile b/docker/api/Dockerfile
new file mode 100644 (file)
index 0000000..a0a6997
--- /dev/null
@@ -0,0 +1,38 @@
+# Arvados API server Docker container.
+
+FROM arvados/base
+MAINTAINER Tim Pierce <twp@clinicalfuture.com>
+
+# TODO(twp): parameterize variables via autoconf or similar.
+ENV POSTGRES_ROOT_PW   dummy_pw
+
+ENV ARVADOS_DEV_DB     arvados_development
+ENV ARVADOS_DEV_USER   arvados
+ENV ARVADOS_DEV_PW     dummy_pw
+
+ENV ARVADOS_TEST_DB    arvados_test
+ENV ARVADOS_TEST_USER  arvados
+ENV ARVADOS_TEST_PW    dummy_pw
+
+ENV ARVADOS_PROD_DB    arvados_production
+ENV ARVADOS_PROD_USER  arvados
+ENV ARVADOS_PROD_PW    dummy_pw
+
+# Install postgres and apache
+RUN apt-get -q -y install procps postgresql postgresql-server-dev-9.1 apache2
+
+# Configure databases and users.
+ADD postgresql_config.sh /tmp/postgresql_config.sh
+RUN /tmp/postgresql_config.sh
+RUN rm /tmp/postgresql_config.sh
+
+# Install gems needed for API server
+RUN bundle install --gemfile=/usr/src/arvados/services/api/Gemfile
+
+# 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 /tmp/config_rake.sh
+
old mode 100644 (file)
new mode 100755 (executable)
index 1eb8664..885b535
@@ -1,8 +1,4 @@
-#! /bin/sh
+#! /bin/bash
 
-# set up the RVM environment
-source /usr/local/rvm/scripts/rvm
-
-/usr/bin/service postgresql start
+/etc/init.d/postgresql start
 rake -f /usr/src/arvados/services/api/Rakefile db:setup
-
index 8044e5d404ccaaf4825ba0e7973896f9cfb04d0a..b864e2863637747e380ed371c97451472f21be3d 100644 (file)
@@ -1,4 +1,4 @@
-# Arvados base image (wheezy+rvm+rails+Arvados source) in Docker
+# Arvados base image (wheezy+rvm+Arvados source) in Docker
 
 # Based on Debian Wheezy
 FROM arvados/debian:wheezy
@@ -6,24 +6,11 @@ MAINTAINER Tim Pierce <twp@clinicalfuture.com>
 
 # TODO(twp): parameterize variables via autoconf or similar.
 ENV RUBY_VERSION_NUM   2.0.0
-ENV POSTGRES_ROOT_PW   dummy_pw
-
-ENV ARVADOS_DEV_DB     arvados_development
-ENV ARVADOS_DEV_USER   arvados
-ENV ARVADOS_DEV_PW     dummy_pw
-
-ENV ARVADOS_TEST_DB    arvados_test
-ENV ARVADOS_TEST_USER  arvados
-ENV ARVADOS_TEST_PW    dummy_pw
-
-ENV ARVADOS_PROD_DB    arvados_production
-ENV ARVADOS_PROD_USER  arvados
-ENV ARVADOS_PROD_PW    dummy_pw
 
 # 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 procps postgresql postgresql-server-dev-9.1 apache2
+RUN apt-get -q -y install git curl
 RUN curl -L https://get.rvm.io | bash -s stable --ruby=${RUBY_VERSION_NUM}
 
 # Set up RVM environment. These are just the env variables created by
@@ -44,17 +31,3 @@ ENV PATH /usr/local/rvm/gems/ruby-2.0.0-p247/bin:/usr/local/rvm/gems/ruby-2.0.0-
 # Download Arvados source.
 RUN git clone git://github.com/clinicalfuture/arvados.git /usr/src/arvados
 
-# Install gems
-RUN bundle install --gemfile=/usr/src/arvados/services/api/Gemfile
-
-# Configure databases and users.
-ADD postgresql_config.sh /tmp/postgresql_config.sh
-RUN /tmp/postgresql_config.sh
-
-# Finish configuration. The remaining steps need PostgreSQL to be running,
-# so they are done in a single step.
-ENV RAILS_ENV production
-ADD database.yml /usr/src/arvados/services/api/config/database.yml
-ADD config_rake.sh /tmp/config_rake.sh
-RUN /tmp/config_rake.sh
-
index ddedb2b355f368436fa4a85f7eb1c8336e6aa6bd..b472ff257eb4a6278d1c2670a0b1a4d8b21efe52 100755 (executable)
@@ -1,7 +1,8 @@
 #! /bin/sh
 
-# create a arvados/debian base image
+# build the base wheezy image
 ./mkimage-debootstrap.sh arvados/debian wheezy http://debian.lcs.mit.edu/debian/
 
-# build the Docker base image
+# build the Docker images
 docker build -t arvados/base base
+docker build -t arvados/api api