[Tile-serving] [openstreetmap/osm2pgsql] Dockerfile for osm2pgsql (#1428)
ImreSamu
notifications at github.com
Mon Mar 15 11:21:26 UTC 2021
@hypervtechnics :
V2. "extreme minimalized version" .
- latest osm2pgsql master
- alpine edge - with the latest compilers ( not stable! )
- luajit [2.2.0-r3](https://pkgs.alpinelinux.org/packages?name=luajit&branch=edge) ???
- multi-layer + ldd config tricks
- march=native -o3 lto ... ( cargo cult optimization ... just delete )
not tested .. for me : ~ `47.5MB`
```Dockerfile
# experimental; save as a 'Dockerfile'
# build: docker build -t osm2pgsql_luajit .
FROM alpine:edge as alpine_build
RUN apk --update-cache add cmake make git g++ boost-dev expat-dev bzip2-dev zlib-dev libpq proj-dev postgresql-dev luajit # lua5.3-dev
# build osm2pgsql latest master
RUN git clone --depth 1 --branch master https://github.com/openstreetmap/osm2pgsql.git
WORKDIR /osm2pgsql/build
RUN mkdir -p /osm2pgsql/build
############################
# <CARGO CULT ON>
# .. cpu native + lto optimization .. only for the local testing .. not portable!
# .. not recomended for normal users.
ARG COMPILE_FLAGS=" -march=native -O3 -flto -fno-semantic-interposition -ffat-lto-objects "
ENV CFLAGS=${COMPILE_FLAGS}
ENV CXXFLAGS=${COMPILE_FLAGS}
ENV OBJCFLAGS=${COMPILE_FLAGS}
ENV FFLAGS=${COMPILE_FLAGS}
ENV LDFLAGS="-flto=auto"
# <CARGO CULT OFF>
#######################
RUN cmake .. -D WITH_LUA=OFF -D WITH_LUAJIT=ON
RUN make -j$(nproc)
RUN make install
RUN /usr/local/bin/osm2pgsql --help
RUN ldd /usr/local/bin/osm2pgsql
# "ldd tricks" - credit: https://gist.github.com/bcardiff/85ae47e66ff0df35a78697508fcb49af
RUN ldd /usr/local/bin/osm2pgsql | tr -s '[:blank:]' '\n' | grep '^/' | \
xargs -I % sh -c 'mkdir -p $(dirname deps%); cp % deps%;'
FROM alpine:edge
# copy deps .. generated by "ldd tricks"
COPY --from=alpine_build /osm2pgsql/build/deps /
# copy osm2pgsql
COPY --from=alpine_build /usr/local/bin/osm2pgsql /usr/local/bin/osm2pgsql
COPY --from=alpine_build /usr/local/share/osm2pgsql/default.style /usr/local/share/osm2pgsql/default.style
COPY --from=alpine_build /usr/local/share/osm2pgsql/empty.style /usr/local/share/osm2pgsql/empty.style
COPY --from=alpine_build /usr/local/share/man/man1/osm2pgsql.1 /usr/local/share/man/man1/osm2pgsql.1
# smoke test
RUN /usr/local/bin/osm2pgsql --help
RUN ldd /usr/local/bin/osm2pgsql
CMD ["/usr/local/bin/osm2pgsql"]
```
--
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/osm2pgsql/discussions/1428#discussioncomment-483390
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/tile-serving/attachments/20210315/f22c9daa/attachment.htm>
More information about the Tile-serving
mailing list