Merge pull request #75 from consbio/addDockerfile

This commit is contained in:
Brendan Ward 2019-08-30 19:18:00 -07:00 committed by GitHub
commit 3e4b902935
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 56 additions and 0 deletions

3
.dockerignore Normal file
View File

@ -0,0 +1,3 @@
**/.git
**/node_modules
mbtiles/testdata/*

24
Dockerfile Normal file
View File

@ -0,0 +1,24 @@
# Stage 1: compile mbtileserver
FROM golang:1.12.9-alpine
WORKDIR /
RUN apk add git build-base
COPY . .
RUN GOOS=linux GO111MODULE=on go build -o /mbtileserver
# Stage 2: start from a smaller image
FROM alpine:3.10.1
WORKDIR /
# Link libs to get around issues using musl
RUN mkdir /lib64 && ln -s /lib/libc.musl-x86_64.so.1 /lib64/ld-linux-x86-64.so.2
# copy the executable to the emptry container
COPY --from=0 /mbtileserver /mbtileserver
# Set the command as the entrypoint, so that it captures any
# command-line arguments passed in
ENTRYPOINT ["/mbtileserver"]

View File

@ -132,6 +132,35 @@ $ kill -HUP <pid>
Reloading the server will cause it to pick up changes to the tiles directory, adding new tilesets and removing any that
are no longer present.
## Docker
Pull the latest image from [Docker Hub](https://hub.docker.com/r/consbio/mbtileserver):
```
docker pull consbio/mbtileserver:latest
```
To build the Docker image locally (named `mbtileserver`):
```
docker build -t mbtileserver -f Dockerfile .
```
To run the Docker container on port 8080 with your tilesets in `<host tile dir>`.
Note that by default, `mbtileserver` runs on port 8000 in the container.
```
docker run --rm -p 8080:8000 -v <host tile dir>:/tilesets -t mbtileserver
```
You can pass in additional command-line arguments to `mbtilesever`, for example, to use
certificates and files in `<host cert dir>` so that you can access the server via HTTPS. The example below uses self-signed certificates generated using
[`mkcert`](https://github.com/FiloSottile/mkcert). This example uses automatic redirects, which causes `mbtileserver` to also listen on port 80 and automatically redirect to 443.
```
docker run --rm -p 80:80 443:443 -v <host tile dir>:/tilesets -v <host cert dir>:/certs/ -t mbtileserver -c /certs/localhost.pem -k /certs/localhost-key.pem -p 443 --redirect
```
## Specifications
- expects mbtiles files to follow version 1.0 of the [mbtiles specification](https://github.com/mapbox/mbtiles-spec). Version 1.1 is preferred.