forked from go-spatial/tegola
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
72 lines (62 loc) · 2.28 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# To build, run in root of tegola source tree:
#
# $ git clone git@github.com:go-spatial/tegola.git or git clone https://github.com/go-spatial/tegola.git
# $ cd tegola
# $ docker build -t tegola .
#
# To use with local files, add file data sources (i.e. Geopackages) and config as config.toml to a
# local directory and mount that directory as a volume at /opt/tegola_config/. Examples:
#
# To display command-line options available:
#
# $ docker run --rm tegola
#
# Example PostGIS use w/ http-based config:
#
# $ docker run -p 8080 tegola --config http://my-domain.com/config serve
#
# Example PostGIS use w/ local config:
# $ mkdir docker-config
# $ cp my-config-file docker-config/config.toml
# $ docker run -v /path/to/docker-config:/opt/tegola_config -p 8080 tegola serve
#
# Example gpkg use:
# $ mkdir docker-config
# $ cp my-config-file docker-config/config.toml
# $ cp my-db.gpkg docker-config/
# $ docker run -v /path/to/docker-config:/opt/tegola_config -p 8080 tegola serve
# Intermediary container for building
FROM golang:1.20.2-alpine3.16 AS build
ARG BUILDPKG="github.com/go-spatial/tegola/internal/build"
ARG VER="Version Not Set"
ARG BRANCH="not set"
ARG REVISION="not set"
ENV VERSION="${VER}"
ENV GIT_BRANCH="${BRANCH}"
ENV GIT_REVISION="${REVISION}"
ENV BUILD_PKG="${BUILDPKG}"
# Only needed for CGO support at time of build, results in no noticable change in binary size
# incurs approximately 1:30 extra build time (1:54 vs 0:27) to install packages. Doesn't impact
# development as these layers are drawn from cache after the first build.
RUN apk update \
&& apk add musl-dev=1.2.3-r2 \
&& apk add gcc=11.2.1_git20220219-r2
# Set up source for compilation
RUN mkdir -p /go/src/github.com/go-spatial/tegola
COPY . /go/src/github.com/go-spatial/tegola
RUN env
# Build binary
RUN cd /go/src/github.com/go-spatial/tegola/cmd/tegola \
&& go build -v \
-ldflags "-w -X '${BUILD_PKG}.Version=${VERSION}' -X '${BUILD_PKG}.GitRevision=${GIT_REVISION}' -X '${BUILD_PKG}.GitBranch=${GIT_BRANCH}'" \
-gcflags "-N -l" \
-o /opt/tegola \
&& chmod a+x /opt/tegola
# Create minimal deployment image, just alpine & the binary
FROM alpine:3.12
RUN apk update \
&& apk add ca-certificates \
&& rm -rf /var/cache/apk/*
COPY --from=build /opt/tegola /opt/
WORKDIR /opt
ENTRYPOINT ["/opt/tegola"]