[openstreetmap/openstreetmap-website] Enable the app to be built using Docker (#1290)

Paul Norman notifications at github.com
Fri Sep 16 05:02:23 UTC 2016


pnorman requested changes on this pull request.

* There should be a COPY or ADD instruction to get the local directory to the docker instance running the rails port. I'm not sure on the semantics of copy vs add, so I don't know which is preferred.
* Because the [configuration docs](https://github.com/openstreetmap/openstreetmap-website/blob/master/CONFIGURE.md) require running a rails console the docker instructions should mention how to do that, as well as how to access the database directly or with psql, which are needed for [populating with osmosis](https://github.com/openstreetmap/openstreetmap-website/blob/master/CONFIGURE.md#populating-the-database) or general debugging.
* I don't feel qualified to review the docker-compose stuff

> +  libreadline-dev \
+  libpq-dev \
+  libxml2-dev \
+  imagemagick \
+  libmagickwand-dev \
+  postgresql-client \
+  nodejs \
+  file
+
+# Setup app location
+RUN mkdir -p /app
+WORKDIR /app
+
+# Install gems
+ADD Gemfile /app/Gemfile
+ADD Gemfile.lock /app/Gemfile.lock

You're adding `Gemfile` and `Gemfile.lock`, but shouldn't they come over when you bring *all* of the files from the local directory into docker?

> +# Install packages
+RUN apt-get update && apt-get install -y --no-install-recommends \
+  build-essential \
+  ruby-dev \
+  libgdbm-dev \
+  libncurses5-dev \
+  libffi-dev \
+  libyaml-dev \
+  libreadline-dev \
+  libpq-dev \
+  libxml2-dev \
+  imagemagick \
+  libmagickwand-dev \
+  postgresql-client \
+  nodejs \
+  file

You should add `&& apt-get clean && rm -rf /var/lib/apt/lists/` to avoid including cache files in the docker image, inflating its size.

> @@ -3,7 +3,7 @@
 These instructions are designed for setting up The Rails Port for development and testing.
 If you want to deploy the software for your own project, then see the notes at the end.
 
-You can install the software directly on your machine, which is the traditional and probably best-supported approach. However, there is an alternative which may be easier: Vagrant. This installs the software into a virtual machine, which makes it easier to get a consistent development environment and may avoid installation difficulties. For Vagrant instructions, see [VAGRANT.md](VAGRANT.md).
+You can install the software directly on your machine following the instructions below. Alternatively there are guides to use either [Vagrant](VAGRANT.md) or [Docker](DOCKER.md).

I would still call running software directly on your machine the traditional and probably best-supported approach.

> +git clone --depth=1 https://github.com/openstreetmap/openstreetmap-website.git
+```
+
+### App configuration
+
+```
+cp config/example.application.yml config/application.yml
+```
+
+### Database
+
+```
+cp config/example.database.yml config/database.yml
+```
+
+Set `username` to postgres and `host` to db leave the password blank

Can this be automated, since we always know what the DB info is when running in docker?

> @@ -0,0 +1,9 @@
+FROM postgres:9.4
+
+ADD docker_postgres.sh docker-entrypoint-initdb.d/docker_postgres.sh
+ADD db/functions/ db/functions/
+ADD lib/quad_tile/ lib/quad_tile/
+
+RUN apt-get update && apt-get install -y make \
+  postgresql-server-dev-all \
+  build-essential

Add cleaning commands as in the `Dockerfile`

> +  libpq-dev \
+  libxml2-dev \
+  imagemagick \
+  libmagickwand-dev \
+  postgresql-client \
+  nodejs \
+  file
+
+# Setup app location
+RUN mkdir -p /app
+WORKDIR /app
+
+# Install gems
+ADD Gemfile /app/Gemfile
+ADD Gemfile.lock /app/Gemfile.lock
+RUN bundle install

In other images I've seen a CMD set so you get a meaningful console when you access it, e.g. `CMD ["python2"]`. Is it possible to do the same here to get a console? `bundle exec rails console` is the command used in [`CONFIGURE.md`](https://github.com/openstreetmap/openstreetmap-website/blob/master/CONFIGURE.md#managing-users)

> @@ -0,0 +1,29 @@
+FROM ruby:2.3-slim
+MAINTAINER OpenStreetMap
+ENV REFRESHED_AT 2016-09-15
+
+# Install packages
+RUN apt-get update && apt-get install -y --no-install-recommends \

These are different than the listed [minimum requirements](https://github.com/openstreetmap/openstreetmap-website/blob/master/INSTALL.md#minimum-requirements). I can understand ruby being different since it's coming from a ruby image and the lack of postgresql, but are there reasons for the other differences?

> +ENV REFRESHED_AT 2016-09-15
+
+# Install packages
+RUN apt-get update && apt-get install -y --no-install-recommends \
+  build-essential \
+  ruby-dev \
+  libgdbm-dev \
+  libncurses5-dev \
+  libffi-dev \
+  libyaml-dev \
+  libreadline-dev \
+  libpq-dev \
+  libxml2-dev \
+  imagemagick \
+  libmagickwand-dev \
+  postgresql-client \

Is this needed for anything other than debugging? I'm okay with keeping it, but if it's only for debugging we should add a comment.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/1290#pullrequestreview-292688
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20160915/2192e7ab/attachment.html>


More information about the rails-dev mailing list