Skip to content

Commit

Permalink
Merge pull request #213 from mmd-osm/patch/docker
Browse files Browse the repository at this point in the history
Updated Dockerfile and lighttpd.conf
  • Loading branch information
mmd-osm committed Jul 4, 2020
2 parents 4b414c4 + 95e8974 commit 53fff92
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 18 deletions.
41 changes: 32 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,45 @@
# vim:set ft=dockerfile:
FROM ubuntu:18.04
FROM ubuntu:20.04 AS builder

MAINTAINER operations@osmfoundation.org
ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update -qq && apt-get install -y gcc g++ make autoconf automake libtool \
libfcgi-dev libxml2-dev libmemcached-dev \
libboost-regex-dev libboost-program-options-dev libboost-system-dev \
libboost-date-time-dev libboost-filesystem-dev \
libboost-locale-dev libcrypto++-dev libyajl-dev \
libpqxx-dev zlib1g-dev --no-install-recommends
RUN apt-get update -qq && \
apt-get install -y gcc g++ make autoconf automake libtool \
libfcgi-dev libxml2-dev libmemcached-dev \
libboost-program-options-dev libboost-system-dev \
libboost-filesystem-dev libboost-locale-dev libcrypto++-dev libyajl-dev \
libpqxx-dev zlib1g-dev \
--no-install-recommends && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

WORKDIR /app

# Copy the main application.
COPY . ./

# Compile, install and remove source
RUN ./autogen.sh && ./configure --enable-yajl && make install && ldconfig && rm -rf /app
RUN ./autogen.sh && \
./configure --enable-static --disable-shared --enable-yajl && \
make && \
strip openstreetmap-cgimap

FROM ubuntu:20.04

RUN apt-get update -qq && \
apt-get install -y \
libfcgi-bin libmemcached11 libboost-locale1.71.0 libboost-program-options1.71.0 \
libxml2 libcrypto++6 libyajl2 libpqxx-6.4 zlib1g \
--no-install-recommends && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

COPY --from=builder /app/openstreetmap-cgimap /usr/local/bin

RUN groupadd -g 61000 cgimap && \
useradd -g 61000 -l -M -s /bin/false -u 61000 cgimap

USER cgimap

ENV CGIMAP_HOST db
ENV CGIMAP_DBNAME openstreetmap
Expand Down
56 changes: 47 additions & 9 deletions lighttpd.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ server.document-root = "/home/matt/Programming/openstreetmap/cgimap/"
# TCP port
server.port = 31337

server.reject-expect-100-with-417 = "disable"

# selecting modules
server.modules = ( "mod_access", "mod_rewrite", "mod_fastcgi" )
server.modules = ( "mod_access", "mod_rewrite", "mod_fastcgi", "mod_proxy", "mod_alias" )

# handling unknown routes
server.error-handler-404 = "/dispatch.map"
Expand All @@ -24,17 +26,40 @@ mimetype.assign = (

#debug.log-request-handling = "enable"



$HTTP["request-method"] == "GET" {
url.rewrite-once = (
"^/api/0\.6/map(\.json)?(\?(.*))?$" => "/dispatch.map",
"^/api/0\.6/(node|way|relation)/[[:digit:]]+$" => "/dispatch.map",
"^/api/0\.6/map(\.(json|xml))?(\?(.*))?$" => "/dispatch.map",
"^/api/0\.6/(node|way|relation)/[[:digit:]]+(\.(json|xml))?$" => "/dispatch.map",
"^/api/0\.6/(node|way|relation)/[[:digit:]]+/history.*$" => "/dispatch.map",
"^/api/0\.6/(node|way|relation)/[[:digit:]]+/[[:digit:]]+.*$" => "/dispatch.map",
"^/api/0\.6/(node|way|relation)/[[:digit:]]+/relations$" => "/dispatch.map",
"^/api/0\.6/node/[[:digit:]]+/ways$" => "/dispatch.map",
"^/api/0\.6/(way|relation)/[[:digit:]]+/full$" => "/dispatch.map",
"^/api/0\.6/changeset/[[:digit:]]+.*$" => "/dispatch.map",
"^/api/0\.6/(nodes|ways|relations)(\?(.*))?$" => "/dispatch.map",
"^/api/0\.6/changeset/[[:digit:]]+/download$" => "/dispatch.map",
)
}
fastcgi.debug = 1

$HTTP["request-method"] == "POST" {
url.rewrite-once = (
"^/api/0\.6/changeset/[[:digit:]]+/upload.*$" => "/dispatch.map",
)
}

$HTTP["request-method"] == "PUT" {
url.rewrite-once = (
"^/api/0\.6/changeset/[[:digit:]]+/close.*$" => "/dispatch.map",
"^/api/0\.6/changeset/[[:digit:]]+$" => "/dispatch.map",
"^/api/0\.6/changeset/create.*$" => "/dispatch.map",
)
}

$HTTP["url"] =~ "^/(?!(dispatch\.map))" {
proxy.server = ( "" => ( ( "host" => "127.0.0.1", "port" => "3000" ) ) )
}

#fastcgi.debug = 1

fastcgi.server = ( ".map" =>
(( "socket" => "/tmp/map-fastcgi.socket",
Expand All @@ -44,11 +69,24 @@ fastcgi.server = ( ".map" =>
"max-procs" => 1,
"check-local" => "disable",
"bin-environment" => (
# "CGIMAP_HOST" => "localhost",
"CGIMAP_HOST" => "localhost",
"CGIMAP_DBNAME" => "apidb",
"CGIMAP_LOGFILE" => "/home/matt/Programming/openstreetmap/cgimap/log",
# "CGIMAP_USERNAME" => "matt",
# "CGIMAP_PASSWORD" => ""
"CGIMAP_USERNAME" => "api",
"CGIMAP_PASSWORD" => "pass"
# "CGIMAP_UPDATE_HOST" => "127.0.0.1",
# "CGIMAP_UPDATE_DBNAME" => "openstreetmap"
)
))
)


# For use with Dockerfile
#
# fastcgi.server = ( ".map" =>
# (( "host" => "127.0.0.1",
# "port" => 8000,
# "check-local" => "disable",
#
# ))
)

0 comments on commit 53fff92

Please sign in to comment.