Skip to content

Commit

Permalink
feat: Set tmp dir and tileset dir via args
Browse files Browse the repository at this point in the history
  • Loading branch information
ff6347 committed Jul 7, 2022
1 parent 5fc2c9e commit 93ba1fb
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,5 @@ dist
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
_data/temp/out.full.geojson
_data/temp/trees.mbtiles
8 changes: 7 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ FROM golang:1.18.3-bullseye
ARG TIPPICANOE_TAG=1.36.0
ARG MBTILESERVER_TAG=0.8.2
ARG GDAL_VERSION=3.2.2+dfsg-2+deb11u1
ARG TILESET_DIR=/tileset
ARG TMP_DIR=/tmp

ENV WORK_DIR /usr/app
ENV TILESET_DIR $TILESET_DIR
ENV TMP_DIR $TMP_DIR

RUN apt-get update && apt-get install -y \
ca-certificates \
Expand All @@ -18,7 +24,7 @@ RUN apt-get update && apt-get install -y \
bash \
g++
RUN go install github.com/consbio/mbtileserver@v${MBTILESERVER_TAG}
WORKDIR /usr/app
WORKDIR ${WORK_DIR}
RUN git clone --depth 1 --branch ${TIPPICANOE_TAG} https://github.com/mapbox/tippecanoe.git && \
cd tippecanoe && \
make -j && \
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ services:
environment:
# these variables are used in the entrypoint.sh script
- TILESET_DIR=/tilesets
- WORK_DIR=/usr/app
- TMP_DIR=/temp
# The values below need to be changed in production
# - POSTGRES_HOST=postgres
# - POSTGRES_DB=postgres
Expand Down
11 changes: 6 additions & 5 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ IFS=$'\n\t'
echo "system: Running $0"
echo "system: Creating tileset directory...$TILESET_DIR"
mkdir -p "$TILESET_DIR"
mkdir -p "$TMP_DIR"

echo "system: Removing old geojson files..."
rm -f "$WORK_DIR"/out.full.geojson || true
rm -f "$TMP_DIR"/out.full.geojson || true

echo "ogr2ogr: Creating geojson file from sql query"
ogr2ogr \
-f GeoJSON "$WORK_DIR"/out.full.geojson \
-f GeoJSON "$TMP_DIR"/out.full.geojson \
"PG:host='$POSTGRES_HOST' \
dbname='$POSTGRES_DB' \
user='$POSTGRES_USER' \
Expand All @@ -21,14 +22,14 @@ ogr2ogr \
echo "tippecanoe: Creating tileset..."
tippecanoe \
-zg \
-o "$WORK_DIR"/trees.mbtiles \
-o "$TMP_DIR"/trees.mbtiles \
--force \
--drop-densest-as-needed \
--extend-zooms-if-still-dropping \
"$WORK_DIR"/out.full.geojson
"$TMP_DIR"/out.full.geojson

echo "system: Copying tileset to tileset directory..."
cp "$WORK_DIR"/trees.mbtiles "$TILESET_DIR"
cp "$TMP_DIR"/trees.mbtiles "$TILESET_DIR"

echo "mbtileserver: Starting tile server with args: $*"
mbtileserver "$@"

0 comments on commit 93ba1fb

Please sign in to comment.