added some stuff lol!
This commit is contained in:
+1
-1
@@ -1,4 +1,4 @@
|
||||
{
|
||||
"schemaVersion": 2,
|
||||
"dockerfilePath": "./Dockerfile"
|
||||
"dockerfilePath": "./docker-compose.yml"
|
||||
}
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
version: "3.9"
|
||||
|
||||
services:
|
||||
postgis:
|
||||
image: postgis/postgis:16-3.4
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
POSTGRES_DB: planner
|
||||
POSTGRES_USER: planner
|
||||
POSTGRES_PASSWORD: change-me
|
||||
volumes:
|
||||
- postgis_data:/var/lib/postgresql/data
|
||||
|
||||
osm-importer:
|
||||
build:
|
||||
context: ./services/osm-importer
|
||||
dockerfile: Dockerfile
|
||||
restart: unless-stopped
|
||||
depends_on:
|
||||
- postgis
|
||||
environment:
|
||||
PBF_URL: https://download.geofabrik.de/europe-latest.osm.pbf
|
||||
PGHOST: postgis
|
||||
PGPORT: "5432"
|
||||
PGDATABASE: planner
|
||||
PGUSER: planner
|
||||
PGPASSWORD: change-me
|
||||
UPDATE_INTERVAL_SECONDS: "86400"
|
||||
volumes:
|
||||
- osm_data:/osm
|
||||
|
||||
martin:
|
||||
image: ghcr.io/maplibre/martin:latest
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
DATABASE_URL: postgres://planner:change-me@postgis:5432/planner
|
||||
depends_on:
|
||||
- postgis
|
||||
|
||||
valhalla:
|
||||
image: ghcr.io/valhalla/valhalla-scripted:latest
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
tile_urls: https://download.geofabrik.de/europe/germany-latest.osm.pbf
|
||||
volumes:
|
||||
- valhalla_data:/custom_files
|
||||
|
||||
traccar:
|
||||
image: traccar/traccar:latest
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "8082:8082"
|
||||
- "5000-5150:5000-5150"
|
||||
- "5000-5150:5000-5150/udp"
|
||||
volumes:
|
||||
- traccar_data:/opt/traccar/data
|
||||
- traccar_logs:/opt/traccar/logs
|
||||
|
||||
planner-api:
|
||||
build: .
|
||||
restart: unless-stopped
|
||||
depends_on:
|
||||
- postgis
|
||||
- martin
|
||||
- valhalla
|
||||
- traccar
|
||||
|
||||
ev-battery-tracker:
|
||||
image: alpine:3.20
|
||||
command: ["sh", "-c", "sleep infinity"]
|
||||
restart: unless-stopped
|
||||
|
||||
traffic-fetcher:
|
||||
image: alpine:3.20
|
||||
command: ["sh", "-c", "sleep infinity"]
|
||||
restart: unless-stopped
|
||||
|
||||
volumes:
|
||||
postgis_data:
|
||||
valhalla_data:
|
||||
traccar_data:
|
||||
traccar_logs:
|
||||
@@ -0,0 +1,8 @@
|
||||
FROM iboates/osm2pgsql:latest
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY osm-import.sh /osm-import.sh
|
||||
RUN chmod +x /osm-import.sh
|
||||
|
||||
CMD ["sh", "/osm-import.sh"]
|
||||
@@ -0,0 +1,61 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
PBF_URL="${PBF_URL:-https://download.geofabrik.de/europe/germany-latest.osm.pbf}"
|
||||
PBF_FILE="${PBF_FILE:-/osm/region.osm.pbf}"
|
||||
|
||||
PGHOST="${PGHOST:-postgis}"
|
||||
PGPORT="${PGPORT:-5432}"
|
||||
PGDATABASE="${PGDATABASE:-planner}"
|
||||
PGUSER="${PGUSER:-planner}"
|
||||
PGPASSWORD="${PGPASSWORD:-change-me}"
|
||||
export PGPASSWORD
|
||||
|
||||
UPDATE_INTERVAL_SECONDS="${UPDATE_INTERVAL_SECONDS:-86400}"
|
||||
|
||||
echo "OSM importer starting..."
|
||||
|
||||
if [ ! -f "$PBF_FILE" ]; then
|
||||
echo "Downloading initial extract from $PBF_URL"
|
||||
wget -O "$PBF_FILE" "$PBF_URL"
|
||||
fi
|
||||
|
||||
if ! psql -h "$PGHOST" -p "$PGPORT" -U "$PGUSER" -d "$PGDATABASE" -tAc \
|
||||
"SELECT 1 FROM pg_tables WHERE tablename = 'planet_osm_point'" | grep -q 1; then
|
||||
echo "Initial osm2pgsql import..."
|
||||
osm2pgsql \
|
||||
--create \
|
||||
--slim \
|
||||
--database "$PGDATABASE" \
|
||||
--host "$PGHOST" \
|
||||
--port "$PGPORT" \
|
||||
--username "$PGUSER" \
|
||||
"$PBF_FILE"
|
||||
else
|
||||
echo "OSM tables already exist, skipping initial import."
|
||||
fi
|
||||
|
||||
if ! psql -h "$PGHOST" -p "$PGPORT" -U "$PGUSER" -d "$PGDATABASE" -tAc \
|
||||
"SELECT 1 FROM pg_tables WHERE tablename = 'planet_osm_replication_status'" | grep -q 1; then
|
||||
echo "Initializing replication..."
|
||||
osm2pgsql-replication init \
|
||||
--database "$PGDATABASE" \
|
||||
--host "$PGHOST" \
|
||||
--port "$PGPORT" \
|
||||
--username "$PGUSER" \
|
||||
--osm-file "$PBF_FILE"
|
||||
else
|
||||
echo "Replication already initialized."
|
||||
fi
|
||||
|
||||
while true; do
|
||||
echo "Running replication update..."
|
||||
osm2pgsql-replication update \
|
||||
--database "$PGDATABASE" \
|
||||
--host "$PGHOST" \
|
||||
--port "$PGPORT" \
|
||||
--username "$PGUSER"
|
||||
|
||||
echo "Sleeping for $UPDATE_INTERVAL_SECONDS seconds..."
|
||||
sleep "$UPDATE_INTERVAL_SECONDS"
|
||||
done
|
||||
Reference in New Issue
Block a user