<p>This PR is primarily intended as a way of concretely demonstrating potential improvements / responding to reviewers in PR <a class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="458248236" data-permission-text="Issue title is private" data-url="https://github.com/openstreetmap/openstreetmap-website/issues/2272" data-hovercard-type="pull_request" data-hovercard-url="/openstreetmap/openstreetmap-website/pull/2272/hovercard" href="https://github.com/openstreetmap/openstreetmap-website/pull/2272">#2272</a> by <a class="user-mention" data-hovercard-type="user" data-hovercard-url="/hovercards?user_id=11360512" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/fazlerabbi37">@fazlerabbi37</a>.</p>
<h3>Notable changes</h3>
<ul>
<li>Reorganized the directory structure based on experience using this structure successfully on several other projects.</li>
<li>Use a <code>postgis</code> Docker image instead of <code>postgres</code> since we definitely need PostGIS.</li>
<li>Combine <code>RUN</code> commands to reduce the number of layers in Docker images.</li>
<li>Don't compile Ruby or install gems in the <code>db</code> image. We just need a single header file in order to build <code>libpgosm.so</code>.</li>
<li>Turns out the <code>docker_postgres.sh</code> script which installs the OSM-specific Postgres extensions wasn't actually being run because of a missing slash. Fixed that _(and renamed the file to include <code>openstreetmap</code> in the name to make its purpose clear).</li>
<li>Switched from <code>ruby:2.5-slim</code> to <code>ruby:2.5</code> since we're installing so much stuff anyway <em>(ok, fine - it's mostly because it has <code>curl</code> installed by default which saves some bootstrapping trouble <g-emoji class="g-emoji" alias="stuck_out_tongue" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/1f61b.png">😛</g-emoji>)</em>. I'm happy to be talked out of this one.</li>
</ul>
<h3>TODO</h3>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> Review and update <code>DOCKER.md</code>. I haven't touched this other than moving it to the top-level directory.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> I wonder if just using an Ubuntu image for <code>web</code> would be easier since we'd get sane Ruby and NodeJS defaults? Additionally, we could just copy/paste the current instructions from <code>INSTALL.md</code> and what is used for Vagrant instead of inventing a separate set of installation instructions.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> Get feedback on the addition of a <code>Makefile</code> at the top level for running <code>docker-compose</code> commands <em>(doesn't seem like that great of an idea)</em>.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> Deal with Postgres persistence. Instructions for this included at <a href="https://hub.docker.com/_/postgres" rel="nofollow">https://hub.docker.com/_/postgres</a></li>
</ul>

<hr>

<h4>You can view, comment on, or merge this pull request online at:</h4>
<p>  <a href='https://github.com/openstreetmap/openstreetmap-website/pull/2406'>https://github.com/openstreetmap/openstreetmap-website/pull/2406</a></p>

<h4>Commit Summary</h4>
<ul>
  <li>Add Dockerfile for rails app</li>
  <li>Modify Dockerfile to fix comment for postgresql-client installation error</li>
  <li>Modify Dockerfile to separate apt cache clean, npm comment, and removed jobs from bundle install</li>
  <li>Add docker_postgres.sh for PostgreSQL extension and functions</li>
  <li>Add Dockerfile.postgres for postgres app</li>
  <li>Add docker-compose.yml to build the complete app</li>
  <li>modify Dockerfile.postgres to fix script path</li>
  <li>modify Dockerfile.postgres to upgrade postgres image to 11</li>
  <li>modify Dockerfile to change postgresql-client package and install phantomjs via npm</li>
  <li>modify docker-compose.yml to fix context path</li>
  <li>add DOCKER.md file with docker setup instructions</li>
  <li>add .dockerignore file to list ignorable file for docker</li>
  <li>modify DOCKER.md to add database population</li>
  <li>modify DOCKER.md to add app config</li>
  <li>moved docker_postgres.sh to docker directory</li>
  <li>modify Dockerfile.postgres file to change pgsql script location</li>
  <li>modify Dockerfile.postgres file to add app location and gem install</li>
  <li>modify Dockerfile.postgres file to move db function directory</li>
  <li>modify docker_postgres.sh to fix libpgosm location</li>
  <li>modify Dockerfile to add osmosis</li>
  <li>modify DOCKER.md to add osmosis instructions</li>
  <li>modify Dockerfile.postgres to add ruby compilation</li>
  <li>modify Dockerfile.postgres to change owner to postgres</li>
  <li>Reorganize docker-compose files</li>
  <li>Require newer version of docker-compose</li>
  <li>Re-org includes following directory re-org</li>
  <li>Use currently 'supported' version of Postgres</li>
  <li>Move 'ADD' later in build process to preserve layer caches</li>
  <li>Dockerfile cleanup to minimize image layers</li>
  <li>Drop unneeded image names from docker-compose.yml</li>
  <li>Update build context for 'db'</li>
  <li>More re-org of main Dockerfile for better layer caching</li>
  <li>Remove dockerignore file for less build surprises</li>
  <li>Fix db Dockerfile path</li>
  <li>Port forward Postgres to a less common port to avoid conflicts</li>
  <li>Rename Postgres init script</li>
  <li>Build shared object in Dockerfile, not at run time</li>
  <li>Use PG11. Don't install Ruby - just get headers for PG extension.</li>
  <li>Add db name to database URL for docker-compose</li>
  <li>Temporary(?) Makefile for docker-compose shortcuts</li>
</ul>

<h4>File Changes</h4>
<ul>
  <li>
    <strong>A</strong>
    <a href="https://github.com/openstreetmap/openstreetmap-website/pull/2406/files#diff-0">DOCKER.md</a>
    (99)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/openstreetmap/openstreetmap-website/pull/2406/files#diff-1">Dockerfile</a>
    (52)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/openstreetmap/openstreetmap-website/pull/2406/files#diff-2">Makefile</a>
    (10)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/openstreetmap/openstreetmap-website/pull/2406/files#diff-3">docker-compose.yml</a>
    (24)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/openstreetmap/openstreetmap-website/pull/2406/files#diff-4">docker/postgres/Dockerfile</a>
    (25)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/openstreetmap/openstreetmap-website/pull/2406/files#diff-5">docker/postgres/openstreetmap-postgres-init.sh</a>
    (7)
  </li>
</ul>

<h4>Patch Links:</h4>
<ul>
  <li><a href='https://github.com/openstreetmap/openstreetmap-website/pull/2406.patch'>https://github.com/openstreetmap/openstreetmap-website/pull/2406.patch</a></li>
  <li><a href='https://github.com/openstreetmap/openstreetmap-website/pull/2406.diff'>https://github.com/openstreetmap/openstreetmap-website/pull/2406.diff</a></li>
</ul>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/openstreetmap/openstreetmap-website/pull/2406?email_source=notifications&email_token=AAK2OLJQ725ODFRB3F3L363QPO53VA5CNFSM4JCSIWE2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HS64IZA">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AAK2OLM3JX4VJBSWMJ6JVDLQPO53VANCNFSM4JCSIWEQ">unsubscribe</a>.<img src="https://github.com/notifications/beacon/AAK2OLLVJHKHDPTTGV2HELTQPO53VA5CNFSM4JCSIWE2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HS64IZA.gif" height="1" width="1" alt="" /></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/openstreetmap/openstreetmap-website/pull/2406?email_source=notifications\u0026email_token=AAK2OLJQ725ODFRB3F3L363QPO53VA5CNFSM4JCSIWE2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HS64IZA",
"url": "https://github.com/openstreetmap/openstreetmap-website/pull/2406?email_source=notifications\u0026email_token=AAK2OLJQ725ODFRB3F3L363QPO53VA5CNFSM4JCSIWE2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HS64IZA",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>