Skip to content

Commit 479d8e8

Browse files
author
Rub21
committed
Add env var file and update container and readme for full-history
1 parent a0c2942 commit 479d8e8

File tree

6 files changed

+69
-72
lines changed

6 files changed

+69
-72
lines changed

.env.full-history.example

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#######################################
2+
# Environment variables for overwrite full history planet PBF settings
3+
#######################################
4+
# OVERWRITE_FHISTORY_FILE=(true, false)
5+
OVERWRITE_FHISTORY_FILE=false
6+
7+
#Osmosis tuning for server, This variable intends to use much as possible the memory in the server
8+
MEMORY_JAVACMD_OPTIONS=2Gi

docker-compose.yml

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@ services:
2727
depends_on:
2828
- db
2929
# ######################################################
30+
# ### OSM processor and also use this image as base for other containers
31+
# ######################################################
32+
osm-processor:
33+
image: osmseed-osm-processor:v1
34+
build:
35+
context: ./images/osm-processor
36+
dockerfile: Dockerfile
37+
# ######################################################
3038
# ### Planet replication section
3139
# ######################################################
3240
planet-dump:
@@ -92,6 +100,28 @@ services:
92100
- ./.env.cloudprovider
93101
depends_on:
94102
- db
103+
######################################################
104+
### OSM full planet replication
105+
######################################################
106+
full-history:
107+
image: osmseed-full-history:v1
108+
build:
109+
context: ./images/full-history
110+
dockerfile: Dockerfile
111+
volumes:
112+
- ./data/full-history-data:/mnt/data
113+
command: >
114+
/bin/bash -c "
115+
echo 'Set cron job for full history PBF file, every 3m minutes';
116+
sleep 1m;
117+
while :; do echo 'Creating full history PBF file...'; /start.sh; sleep 3m; done;
118+
"
119+
env_file:
120+
- ./.env.db
121+
- ./.env.full-history
122+
- ./.env.cloudprovider
123+
depends_on:
124+
- db
95125
# ######################################################
96126
# ### OSM data restoring into the database
97127
# ######################################################
@@ -101,7 +131,7 @@ services:
101131
# context: ./images/populate-apidb
102132
# dockerfile: Dockerfile
103133
# volumes:
104-
# - ./populate-apidb-data:/app/data
134+
# - ./data/populate-apidb-data:/app/data
105135
# depends_on:
106136
# - db
107137
# command: >
@@ -112,34 +142,6 @@ services:
112142
# ./start.sh"
113143
# env_file:
114144
# - ./.env
115-
# osm-processor:
116-
# image: osmseed-osm-processor:v1
117-
# build:
118-
# context: ./images/osm-processor
119-
# dockerfile: Dockerfile
120-
# env_file:
121-
# - ./.env
122-
# ######################################################
123-
# ### OSM full planet replication
124-
# ######################################################
125-
# full-history:
126-
# image: osmseed-full-history:v1
127-
# build:
128-
# context: ./images/full-history
129-
# dockerfile: Dockerfile
130-
# depends_on:
131-
# - web
132-
# - db
133-
# volumes:
134-
# - ./full-history-data:/mnt/data
135-
# command: >
136-
# /bin/bash -c "
137-
# echo Sleep full-history for a while!;
138-
# sleep 40;
139-
# echo Starting full-history!;
140-
# ./start.sh"
141-
# env_file:
142-
# - ./.env
143145
# ######################################################
144146
# ### Tiler server(tegola), Database and imposm section
145147
# ######################################################

images/full-history/Dockerfile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
FROM developmentseed/osmseed-osm-processor:0.1.0-n487.hbce9469
2-
WORKDIR /mnt/data
3-
COPY ./start.sh .
4-
CMD ./start.sh
2+
3+
VOLUME /mnt/data
4+
COPY ./start.sh /
5+
CMD /start.sh

images/full-history/README.md

Lines changed: 17 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,46 +2,28 @@
22

33
Dockerfile for getting the full planet history of database.
44

5-
65
### Configuration
76

8-
Required environment variables;
9-
10-
- `POSTGRES_HOST`
11-
- `POSTGRES_DB`
12-
- `POSTGRES_USER`
13-
- `POSTGRES_PASSWORD`
14-
15-
The following env variables are according to which cloud provider you are going to use:
16-
17-
- `CLOUDPROVIDER`, eg. `aws` or `gcp`
18-
19-
In case AWS:
20-
21-
- `AWS_S3_BUCKET` e.g `s3://osm-seed-test`
7+
In order to run this container we need environment variables, these can be found in the following files👇:
228

23-
In case GCP:
9+
- [.env.db.example](./../../.env.db.example)
10+
- [.env.full-history.example](./../../.env.full-history.example)
11+
- [.env.cloudprovider.example](./../../.env.cloudprovider.example)
2412

25-
- `GCP_STORAGE_BUCKET` e.g `gs://osm-seed-test`
13+
**Note**: Rename the above files as `.env.db`, `.env.full-history` and `.env.cloudprovider`
2614

27-
By default, the container create a new *.osm.bz2 file, if you want to overwrite the same file as `history-latest.osm.bz2` set the following env var 👇;
28-
29-
- `OVERWRITE_FHISTORY_FILE=yes`
30-
31-
32-
#### Building the container
15+
#### Running full-history container
3316

3417
```sh
35-
cd full-history
36-
docker build -t full-history:v1 .
18+
# Docker compose
19+
docker-compose run full-history
20+
21+
# Docker
22+
docker run \
23+
--env-file ./../.env.db \
24+
--env-file ./../.env.full-history \
25+
--env-file ./../.env.cloudprovider \
26+
-v ${PWD}/data/full-history-data:/mnt/data \
27+
--network osm-seed_default \
28+
-it osmseed-full-history:v1
3729
```
38-
39-
#### Running the container
40-
41-
```sh
42-
docker run \
43-
--env-file ./../.env \
44-
-v ${PWD}:/mnt/data \
45-
--network osm-seed_default \
46-
-it full-history:v1
47-
```

images/full-history/start.sh

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env bash
2+
export VOLUME_DIR=/mnt/data
23

34
# osmosis tuning: https://wiki.openstreetmap.org/wiki/Osmosis/Tuning,https://lists.openstreetmap.org/pipermail/talk/2012-October/064771.html
45
if [ -z "$MEMORY_JAVACMD_OPTIONS" ]; then
@@ -10,14 +11,14 @@ fi
1011

1112
# Fixing name for historical file
1213
date=$(date '+%y%m%d_%H%M')
13-
fullHistoryFile=history-${date}.osh.pbf
14+
fullHistoryFile=$VOLUME_DIR/history-${date}.osh.pbf
1415
# In case overwrite the file
1516
if [ "$OVERWRITE_FHISTORY_FILE" == "true" ]; then
16-
fullHistoryFile=history-latest.osh.pbf
17+
fullHistoryFile=$VOLUME_DIR/history-latest.osh.pbf
1718
fi
1819

1920
# State file nname
20-
stateFile="state.txt"
21+
stateFile="$VOLUME_DIR/state.txt"
2122
osm_tmp_file="osm_tmp.osm"
2223

2324
# Creating full history
@@ -36,6 +37,9 @@ osmosis --read-apidb-change \
3637
osmium cat $osm_tmp_file -o $fullHistoryFile
3738
osmium fileinfo $fullHistoryFile
3839

40+
# Remove full-hitory osm file, keep only history-latest.osh.pbf files
41+
rm $osm_tmp_file
42+
3943
# AWS
4044
if [ $CLOUDPROVIDER == "aws" ]; then
4145
AWS_URL=${AWS_S3_BUCKET/s3:\/\//http:\/\/}
@@ -45,7 +49,7 @@ if [ $CLOUDPROVIDER == "aws" ]; then
4549
aws s3 cp $stateFile $AWS_S3_BUCKET/planet/full-history/$stateFile --acl public-read
4650
fi
4751

48-
# Google Storage
52+
# Google Storagegit status
4953
if [ $CLOUDPROVIDER == "gcp" ]; then
5054
echo "https://storage.cloud.google.com/$GCP_STORAGE_BUCKET/planet/full-history/$fullHistoryFile" >$stateFile
5155
# Upload to GS

osm-seed/templates/full-history-job.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ spec:
2121
containers:
2222
- name: {{ .Release.Name }}-full-history-job
2323
image: {{ .Values.fullHistory.image.name }}:{{ .Values.fullHistory.image.tag }}
24-
command: ['./start.sh']
24+
command: ['/start.sh']
2525
{{- if .Values.fullHistory.resources.enabled }}
2626
resources:
2727
requests:

0 commit comments

Comments
 (0)