Skip to content
Closed
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
ad237cd
Add Dockerfile for rails app
fazlerabbi37 Jun 19, 2019
3fe73f0
Modify Dockerfile to fix comment for postgresql-client installation e…
fazlerabbi37 Jun 19, 2019
4eeb36a
Modify Dockerfile to separate apt cache clean, npm comment, and remov…
fazlerabbi37 Jun 20, 2019
caaa350
Add docker_postgres.sh for PostgreSQL extension and functions
fazlerabbi37 Jun 20, 2019
b6d373f
Add Dockerfile.postgres for postgres app
fazlerabbi37 Jun 20, 2019
30ad01e
Add docker-compose.yml to build the complete app
fazlerabbi37 Jun 20, 2019
447c55e
modify Dockerfile.postgres to fix script path
fazlerabbi37 Jul 21, 2019
0cf0d0c
modify Dockerfile.postgres to upgrade postgres image to 11
fazlerabbi37 Jul 21, 2019
18ef6b6
modify Dockerfile to change postgresql-client package and install pha…
fazlerabbi37 Jul 21, 2019
f75eea4
modify docker-compose.yml to fix context path
fazlerabbi37 Jul 21, 2019
0d15f1c
add DOCKER.md file with docker setup instructions
fazlerabbi37 Jul 21, 2019
c4c450f
add .dockerignore file to list ignorable file for docker
fazlerabbi37 Jul 21, 2019
076073b
modify DOCKER.md to add database population
fazlerabbi37 Jul 23, 2019
fc139b0
modify DOCKER.md to add app config
fazlerabbi37 Sep 6, 2019
29f6833
Merge branch 'master' into docker
fazlerabbi37 Sep 9, 2019
ce38a10
moved docker_postgres.sh to docker directory
fazlerabbi37 Sep 9, 2019
b03bfd1
modify Dockerfile.postgres file to change pgsql script location
fazlerabbi37 Sep 9, 2019
c6edb29
modify Dockerfile.postgres file to add app location and gem install
fazlerabbi37 Sep 9, 2019
8383453
modify Dockerfile.postgres file to move db function directory
fazlerabbi37 Sep 9, 2019
cb96ddd
modify docker_postgres.sh to fix libpgosm location
fazlerabbi37 Sep 9, 2019
a1413af
modify Dockerfile to add osmosis
fazlerabbi37 Sep 10, 2019
02851d2
modify DOCKER.md to add osmosis instructions
fazlerabbi37 Sep 10, 2019
6ce9e77
modify Dockerfile.postgres to add ruby compilation
fazlerabbi37 Sep 10, 2019
004227e
modify Dockerfile.postgres to change owner to postgres
fazlerabbi37 Sep 10, 2019
96383be
Merge branch 'master' into docker
fazlerabbi37 Sep 20, 2019
35ad5bd
Merge branch 'master' into docker
fazlerabbi37 Sep 24, 2019
4900551
Merge branch 'master' into docker
fazlerabbi37 Oct 6, 2019
7dd9810
Merge branch 'master' of https://github.com/openstreetmap/openstreetm…
fazlerabbi37 Oct 16, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions db/docker_postgres.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
set -e
psql -v ON_ERROR_STOP=1 -U "$POSTGRES_USER" -c "CREATE EXTENSION btree_gist" openstreetmap
make -C db/functions libpgosm.so
psql -v ON_ERROR_STOP=1 -U "$POSTGRES_USER" -c "CREATE FUNCTION maptile_for_point(int8, int8, int4) RETURNS int4 AS '/db/functions/libpgosm', 'maptile_for_point' LANGUAGE C STRICT" openstreetmap
psql -v ON_ERROR_STOP=1 -U "$POSTGRES_USER" -c "CREATE FUNCTION tile_for_point(int4, int4) RETURNS int8 AS '/db/functions/libpgosm', 'tile_for_point' LANGUAGE C STRICT" openstreetmap
psql -v ON_ERROR_STOP=1 -U "$POSTGRES_USER" -c "CREATE FUNCTION xid_to_int4(xid) RETURNS int4 AS '/db/functions/libpgosm', 'xid_to_int4' LANGUAGE C STRICT" openstreetmap
28 changes: 28 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
FROM ruby:2.5-slim

#install packages
#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
RUN apt-get update && apt-get install curl -y

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Each time apt-get is run you should update and then remove the APT cache files at the end of the command.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So that the cache files don't make it into the docker image

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this just building a container for local use though? Not anything that's going to be published?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, but what I've read indicates it as a best practice in general

RUN apt-get clean && rm -rf /var/lib/apt/lists/*
#npm is not available in Debian repo so following official instruction [source: https://github.com/nodesource/distributions/blob/master/README.md#debinstall]
RUN curl -sL https://deb.nodesource.com/setup_10.x -o nodesource_setup.sh && bash nodesource_setup.sh && rm nodesource_setup.sh
RUN apt-get install -y --no-install-recommends ruby-dev libarchive-dev libmagickwand-dev libxml2-dev libxslt1-dev build-essential libpq-dev libsasl2-dev imagemagick libffi-dev locales postgresql-client-9.6 nodejs
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
RUN npm install yarn -g

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docs state bundle exec rake yarn:install. If there's a reason to differ, can you add a comment?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Different thing - you need to install yarn first (unfortunately it's not packaged in Ubuntu like it is in Fedora) and then bundle exec rake yarn:install runs yarn to install the modules listed in package.json.


# 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
8 changes: 8 additions & 0 deletions docker/Dockerfile.postgres
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM postgres:11

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Production still uses 9.5 as of now.

ADD db/docker_postgres.sh docker-entrypoint-initdb.d/docker_postgres.sh
ADD db/functions/ db/functions/

RUN apt-get update
RUN apt-get install -y make build-essential postgresql-server-dev-all
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
23 changes: 23 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
version: '2'
services:
web:
image: openstreetmap-website:v1
build:
context: ..

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not put the Dockerfiles in this directory?

@fazlerabbi37 fazlerabbi37 Jul 22, 2019

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which directory? Right now all docker related files are in one directory named docker.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh wait, nevermind.

dockerfile: docker/Dockerfile
volumes:
- .:/app
ports:
- "3000:3000"
command: bundle exec rails s -p 3000 -b '0.0.0.0'
depends_on:
- db
db:
image: openstreetmap-db:v1
build:
context: ..

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here as above?

dockerfile: docker/Dockerfile.postgres
ports:
- "5432:5432"
environment:
POSTGRES_DB: openstreetmap