mapbox / tippecanoe

Build vector tilesets from large collections of GeoJSON features.
BSD 2-Clause "Simplified" License
2.72k stars 432 forks source link

How to build tippecanoe inside my own Dockerfile? #651

Open constantinevassil opened 6 years ago

constantinevassil commented 6 years ago

I would like to build tippecanoe inside my own Dockerfile based on Debian. How to do that?

e-n-f commented 6 years ago

https://github.com/mapbox/tippecanoe/blob/master/Dockerfile is an example of a Dockerfile that builds Tippecanoe (and then runs its tests).

constantinevassil commented 6 years ago

Eric,

I tried with Ubuntu and also CentOS Docker images.

I do the following in the Dockerimage: 1) Install tippecanoe 2) Golang 3) Golang server 4) in Golang server I have a handler like this: cmd := exec.Command("bash", "/cmd.sh") 5) in cmd.sh - the following command for testing: tippecanoe --version

when executing this command I get an error

e-n-f commented 6 years ago

If you don't say what the error is, I can't help much. Perhaps your tippecanoe script just does make instead of make install, so it is only built in the local directory instead of installed in /usr/local/bin? Perhaps /usr/local/bin isn't in your $PATH?

thstart commented 6 years ago

Would it work with Alpine?

constantinevassil commented 6 years ago

There a lot of warnings:

g++ -MMD -I/usr/local/include -I. -g -Wall -Wshadow -Wsign-compare -Wextra -Wunreachable-code -Wuninitialized -Wshadow -O3 -DNDEBUG -std=c++11 -c -o geojson.o geojson.cpp In file included from geojson.hpp:10:0, from geojson.cpp:33: serial.hpp:96:22: warning: missing initializer for member 'stat::st_dev' [-Wmissing-field-initializers] struct stat geomst {}; ^ serial.hpp:96:22: warning: missing initializer for member 'stat::st_ino' [-Wmissing-field-initializers] serial.hpp:96:22: warning: missing initializer for member 'stat::st_nlink' [-Wmissing-field-initializers] serial.hpp:96:22: warning: missing initializer for member 'stat::st_mode' [-Wmissing-field-initializers] serial.hpp:96:22: warning: missing initializer for member 'stat::st_uid' [-Wmissing-field-initializers] serial.hpp:96:22: warning: missing initializer for member 'stat::st_gid' [-Wmissing-field-initializers] serial.hpp:96:22: warning: missing initializer for member 'stat::__pad0' [-Wmissing-field-initializers] serial.hpp:96:22: warning: missing initializer for member 'stat::st_rdev' [-Wmissing-field-initializers] serial.hpp:96:22: warning: missing initializer for member 'stat::st_size' [-Wmissing-field-initializers] serial.hpp:96:22: warning: missing initializer for member 'stat::st_blksize' [-Wmissing-field-initializers] serial.hpp:96:22: warning: missing initializer for member 'stat::st_blocks' [-Wmissing-field-initializers] serial.hpp:96:22: warning: missing initializer for member 'stat::st_atim' [-Wmissing-field-initializers] serial.hpp:96:22: warning: missing initializer for member 'stat::st_mtim' [-Wmissing-field-initializers] serial.hpp:96:22: warning: missing initializer for member 'stat::st_ctim' [-Wmissing-field-initializers] serial.hpp:96:22: warning: missing initializer for member 'stat::__unused' [-Wmissing-field-initializers] serial.hpp:97:22: warning: missing initializer for member 'stat::st_dev' [-Wmissing-field-initializers]

e-n-f commented 6 years ago

This particular warning only happens on Linux, where the system headers for struct stat aren't initialized and aren't tagged in such a way that the compiler knows that they are system headers. Unfortunately as far as I know there isn't a way to avoid these warnings while continuing to warn of legitimate failures to initialize fields within Tippecanoe itself.

geeknik commented 6 years ago

Not sure how helpful this is but gcc has pragmas that disable individual warnings. Each warning message indicates the message's corresponding option, and this is what you stick into the pragma:

https://gcc.gnu.org/onlinedocs/gcc/Diagnostic-Pragmas.html

constantinevassil commented 5 years ago

To save building time I created Tippecanoe binary in a Docker image and then made a copy of the binaries to another Docker image. It saves time for building it every time and space.

I need it to be in Alpine and did it the following way:

Dockerfile:

FROM alpine:3.8

RUN apk update && apk upgrade

Build dependencies

RUN apk add --no-cache --virtual bash RUN apk add --no-cache --virtual g++ RUN apk add --no-cache --virtual make RUN apk add --no-cache --virtual git RUN apk add --no-cache --virtual sqlite-dev RUN apk add --no-cache --virtual zlib-dev

Runtime dependencies

RUN apk add --no-cache --virtual libgcc RUN apk add --no-cache --virtual libstdc++ RUN apk add --no-cache --virtual sqlite-libs

Configuration

WORKDIR /docker/

Working

RUN git clone --depth=1 https://github.com/mapbox/tippecanoe.git RUN make install -j --directory=tippecanoe

Cleanup configuration

RUN rm -rf /docker/

Remove build dependencies

RUN apk del zlib-dev RUN apk del sqlite-dev RUN apk del git RUN apk del make RUN apk del g++ RUN apk del bash

Then upload to Google Repository: gcr.io/my/tippecanoe

Then I invoke from another Dockerfile:

Runtime dependencies

RUN apk add --no-cache --virtual libgcc RUN apk add --no-cache --virtual libstdc++ RUN apk add --no-cache --virtual sqlite-libs

COPY --from=gcr.io/my/tippecanoe /usr/local/bin/tippecanoe /usr/local/bin/tippecanoe COPY --from=gcr.io/my/tippecanoe /usr/local/bin/tippecanoe-enumerate /usr/local/bin/tippecanoe-enumerate COPY --from=gcr.io/my/tippecanoe /usr/local/bin/tippecanoe-decode /usr/local/bin/tippecanoe-decode COPY --from=gcr.iomy/tippecanoe /usr/local/bin/tippecanoe-json-tool /usr/local/bin/tippecanoe-json-tool COPY --from=gcr.io/my/tippecanoe /usr/local/bin/tile-join /usr/local/bin/tile-join

Then run the tile-join inside the second Docker image. It is not working - I suppose I need to install additional runtime dependencies.

I have these:

Runtime dependencies

RUN apk add --no-cache --virtual libgcc RUN apk add --no-cache --virtual libstdc++ RUN apk add --no-cache --virtual sqlite-libs

What more I need?