[openstreetmap/openstreetmap-website] Add Docker Compose Support for Development Environment (#2409)

Andy Allan notifications at github.com
Wed Oct 30 10:06:06 UTC 2019


gravitystorm requested changes on this pull request.

Overall looks great to me! Just a few changes required to bring this into line with INSTALL.md

Talking of which, there should be a paragraph added to the top of INSTALL.md to describe that you can use Docker to set up your development environment, just like you can with Vagrant.

> @@ -0,0 +1,52 @@
+FROM ruby:2.5
+
+# fixes dpkg man page softlink error while installing postgresql-client [source: https://stackoverflow.com/a/52655008/5350059]
+RUN mkdir -p /usr/share/man/man1 && \
+    mkdir -p /usr/share/man/man7
+
+# npm is not available in Debian repo so following official instruction [source: https://github.com/nodesource/distributions/blob/master/README.md#debinstall]

I have more knowledge of Ubuntu than Debian, but as far as I can tell:

* ruby:2.5 is an alias for ruby:2.5-buster (https://hub.docker.com/_/ruby/)
* buster contains npm (https://packages.debian.org/buster/npm)
* but we don't need npm anyway, only `nodejs` and `yarn`


> +      libmagickwand-dev \
+      libpq-dev \
+      libsasl2-dev \
+      libxml2-dev \
+      libxslt1-dev \
+      locales \
+      nodejs \
+      osmosis \
+      postgresql-client \
+      ruby-dev && \
+    apt-get clean && \
+    rm -rf /var/lib/apt/lists/*
+
+# install npm packages
+RUN npm install -g --unsafe-perm \
+      phantomjs-prebuilt \

[Debian buster comes with a phantomjs package](https://packages.debian.org/buster/phantomjs). Should we just install that instead?

> +      libpq-dev \
+      libsasl2-dev \
+      libxml2-dev \
+      libxslt1-dev \
+      locales \
+      nodejs \
+      osmosis \
+      postgresql-client \
+      ruby-dev && \
+    apt-get clean && \
+    rm -rf /var/lib/apt/lists/*
+
+# install npm packages
+RUN npm install -g --unsafe-perm \
+      phantomjs-prebuilt \
+      yarn

I find using npm to install yarn a bit of a roundabout way to go. Could we [install the yarn package using the yarn repository](https://yarnpkg.com/en/docs/install#debian-stable) instead?

> +    docker-compose run --rm web osmosis \
+        -verbose    \
+        --read-pbf district-of-columbia-latest.osm.pbf \
+        --write-apidb \
+            host="db" \
+            database="openstreetmap" \
+            user="openstreetmap" \
+            validateSchemaVersion="no"
+
+Once you have data loaded for Washington, DC you should be able to navigate to `http://localhost:3000/#map=12/38.8938/-77.0146` to begin working with your local instance.
+
+### Additional Configuration
+
+See `CONFIGURE.md` for information on how to manage users and enable OAuth for iD, JOSM etc.
+
+### Tests

Running the tests section should come before the loading an extract or additional configuration sections. This is because the goal for the user is to ensure their development environment is set up correctly, as validated by the tests

> @@ -0,0 +1,100 @@
+# Using Docker and Docker Compose to run OpenStreetMap

"Using Docker and Docker Compose  to set up The Rails Port for development and testing" - based on the wording in the current INSTALL.md and to make it clear that these docker images are designed for development and testing, not necessarily for production.

> +If this is your first time running or you have removed cache this will take some time to complete. Once the Docker images have finished building you can launch the images as containers.
+
+To launch the app run:
+
+    docker-compose up -d
+
+This will launch one Docker container for each 'service' specified in `docker-compose.yml` and run them in the background. There are two options for inspecting the logs of these running containers:
+
+- You can tail logs of a running container with a command like this: `docker-compose logs -f web` or `docker-compose logs -f db`.
+- Instead of running the containers in the background with the `-d` flag, you can launch the containers in the foreground with `docker-compose up`. The downside of this is that the logs of all the 'services' defined in `docker-compose.yml` will be intermingled. If you don't want this you can mix and match - for example, you can run the database in background with `docker-compose up -d db` and then run the Rails app in the foreground via `docker-compose up web`.
+
+### Migrations
+
+Run the Rails database migrations:
+
+    docker-compose run --rm web rake db:migrate

For consistency and reliability, we should have `... bundle exec rake db:migrate` here

> +        --read-pbf district-of-columbia-latest.osm.pbf \
+        --write-apidb \
+            host="db" \
+            database="openstreetmap" \
+            user="openstreetmap" \
+            validateSchemaVersion="no"
+
+Once you have data loaded for Washington, DC you should be able to navigate to `http://localhost:3000/#map=12/38.8938/-77.0146` to begin working with your local instance.
+
+### Additional Configuration
+
+See `CONFIGURE.md` for information on how to manage users and enable OAuth for iD, JOSM etc.
+
+### Tests
+
+    docker-compose run --rm web rake test:db

bundle exec

> +
+# Setup app location
+RUN mkdir -p /app
+WORKDIR /app
+
+# Install gems
+ADD Gemfile* /app/
+RUN bundle install
+
+# Setup local
+RUN sed -i -e 's/# en_GB.UTF-8 UTF-8/en_GB.UTF-8 UTF-8/' /etc/locale.gen && \
+    echo 'LANG="en_GB.UTF-8"'>/etc/default/locale && \
+    dpkg-reconfigure --frontend=noninteractive locales && \
+    update-locale LANG=en_GB.UTF-8
+
+ENV LANG en_GB.UTF-8

There needs to be a bit about `bundle exec rake yarn:install` somewhere, either here in the docker config, or elsewhere in the manual installation notes.

-- 
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/2409#pullrequestreview-309068574
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20191030/5a1b56b7/attachment.html>


More information about the rails-dev mailing list