Skip to content

Commit 9b38b38

Browse files
author
Jin IGARASHI
committed
added docker
1 parent 7cae6c8 commit 9b38b38

9 files changed

+131
-6942
lines changed

.dockerignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
node_modules
2+
npm-debug.log
3+
*.mbtiles
4+
*.pbf
5+
docs/zxy
6+
docs/style.json

.env.example

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
REGION=africa
2+
AREA=rwanda

.gitignore

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
docs/zxy
22
mapbox-gl-js
3-
tiles.mbtiles
4-
src/*.pbf
3+
docs/style.json
4+
*.pbf
5+
*.mbtiles
56

67
# Logs
78
logs

Dockerfile

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
FROM node:12
2+
WORKDIR /usr/src/app
3+
4+
RUN apt-get update && apt-get -y upgrade &&\
5+
apt-get install -y curl &&\
6+
curl -sL https://deb.nodesource.com/setup_12.x | bash -&&\
7+
curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -&&\
8+
echo "deb https://dl.yarnpkg.com/debian/ stable main" |\
9+
tee /etc/apt/sources.list.d/yarn.list
10+
11+
RUN apt-get update &&\
12+
apt-get install -y \
13+
autoconf \
14+
automake \
15+
libboost-program-options-dev \
16+
libbz2-dev \
17+
cmake \
18+
expat \
19+
gdal-bin \
20+
git \
21+
libsqlite3-dev \
22+
libtool \
23+
nginx \
24+
nodejs \
25+
pandoc \
26+
rapidjson-dev \
27+
ruby \
28+
sqlite3 \
29+
tmux \
30+
vim \
31+
xrdp \
32+
yarn \
33+
zip \
34+
zlib1g-dev
35+
36+
RUN mkdir osmium &&\
37+
cd osmium &&\
38+
git clone https://github.com/mapbox/protozero &&\
39+
git clone https://github.com/osmcode/libosmium &&\
40+
git clone https://github.com/osmcode/osmium-tool &&\
41+
cd osmium-tool &&\
42+
mkdir build &&\
43+
cd build &&\
44+
cmake .. &&\
45+
make &&\
46+
make install &&\
47+
cd /usr/src/app &&\
48+
rm -rf usmium
49+
50+
RUN git clone https://github.com/mapbox/tippecanoe &&\
51+
cd tippecanoe; make -j3 LDFLAGS="-latomic"; make install; cd .. &&\
52+
rm -rf tippecanoe
53+
54+
RUN yarn global add browserify budo hjson pm2 rollup @mapbox/mapbox-gl-style-spec @pushcorn/hocon-parser
55+
56+
RUN git clone https://github.com/ibesora/vt-optimizer &&\
57+
cd vt-optimizer; npm install; cd ..
58+
59+
RUN gem install mdless hocon
60+
61+
COPY . /usr/src/app/
62+
63+
WORKDIR /usr/src/app/
64+
65+
RUN rake inet:install
66+
67+
CMD ["/bin/bash"]

README.md

+26
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ curl -sL https://unvt.github.io/equinox/install.sh | bash -
1515
git clone https://github.com/unvt/naru.git
1616
cd naru
1717
rake inet:install # install extra software
18+
# specify OSM regison and area for tiles
19+
export REGION=africa
20+
export AREA=rwanda
1821
rake inet:download # donwload source geospatial data for exercise
1922
```
2023

@@ -50,5 +53,28 @@ Now it is OK to disconnect Raspberry Pi.
5053
### policy
5154
the list shall be minimized, moving items to `equinox`.
5255

56+
## Run on Docker
57+
58+
- for creating `tiles.mbtiles` from the latest osm.pbf
59+
```
60+
docker build . --tag unvt/naru
61+
docker run -it unvt/naru
62+
63+
cd /usr/src/app
64+
export REGION=africa
65+
export AREA=rwanda
66+
rake inet:download # download osm.obf
67+
rake tiles # create mbtiles under src folder
68+
rake style # create style.json
69+
```
70+
71+
- for hosting tiles after creating by UNVT
72+
```
73+
docker build . --tag unvt/naru
74+
cp .env.example .env
75+
vi .env # specify your target REGION and AREA on .env file
76+
docker-compose up
77+
```
78+
5379
# About the name
5480
*naru* means "to be implemented" in traditional Japanese. It was taken from "いづ方をも捨てじと心にとり持ちては、一事もなるべからず" of 徒然草 一八八, which roughly means "If you try to take care of everything, nothing can be implemented."

Rakefile

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
#REGION = 'australia-oceania'
2-
REGION = 'africa'
3-
#AREA = 'new-zealand'
4-
AREA = 'kenya'
1+
REGION = ENV['REGION']
2+
AREA = ENV['AREA']
3+
MBTILES = "src/tiles.mbtiles"
54

65
namespace :inet do
76
desc 'install extra software for naru'
@@ -33,8 +32,8 @@ end
3332

3433
desc 'build tiles from source data'
3534
task :tiles do
36-
sh "osmium export --config osmium-export-config.json --index-type=sparse_file_array --output-format=geojsonseq --output=- src/#{AREA}-latest.osm.pbf | node filter.js | tippecanoe --no-feature-limit --no-tile-size-limit --force --simplification=2 --maximum-zoom=15 --base-zoom=15 --hilbert --output=tiles.mbtiles"
37-
sh "tile-join --force --no-tile-compression --output-to-directory=docs/zxy --no-tile-size-limit tiles.mbtiles"
35+
sh "osmium export --config osmium-export-config.json --index-type=sparse_file_array --output-format=geojsonseq --output=- src/#{AREA}-latest.osm.pbf | node filter.js | tippecanoe --no-feature-limit --no-tile-size-limit --force --simplification=2 --maximum-zoom=15 --base-zoom=15 --hilbert --output=#{MBTILES}"
36+
sh "tile-join --force --no-tile-compression --output-to-directory=docs/zxy --no-tile-size-limit #{MBTILES}"
3837
end
3938

4039
desc 'build style.json from HOCON descriptions'

docker-compose.yml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
version: '3'
2+
3+
services:
4+
naru:
5+
image: unvt/naru
6+
build:
7+
dockerfile: Dockerfile
8+
context: .
9+
entrypoint: '/usr/src/app/entrypoint.sh'
10+
volumes:
11+
- ./docs:/usr/src/app/docs
12+
- ./src:/usr/src/app/src
13+
env_file: .env
14+
ports:
15+
- "9966:9966"

0 commit comments

Comments
 (0)