wiktorn / Overpass-API

Overpass API docker image
MIT License
134 stars 48 forks source link

How to use the predownloaded osm.bz file when initializing docker? #60

Closed csui12042020 closed 3 years ago

csui12042020 commented 3 years ago

It is not really an issue, I would just like to know on how can we use local file as source for OSM_PLANET_URL parameter. I have read from the update that file:/// scheme is now supported in OSM_PLANET_URL parameter. I tried several ways but have encountered several errors like:

1.) OVERPASS_PLANET_URL=file://C:/file/path/to/sample.osm.bz2 error: curl: (3) Valid host name with slash missing in URL

2.) OVERPASS_PLANET_URL=file:///C:/file/path/to/sample.osm.bz2 error: curl: (37) Couldn't open file /C:/file/path/to/sample.osm.bz2

3.) OVERPASS_PLANET_URL='file:///C:/file/path/to/sample.osm.bz2' error: curl: (1) Protocol "'file" not supported or disabled in libcurl

I hope you can provide some assistance. Thank you

wiktorn commented 3 years ago

Your file:/// url looks strange for me. Are you sure, that this URL is valid within your docker instance?

Franky1 commented 3 years ago

There is always confusion because of the slashes... forward, backward... i assume you are running on Windows? I haven't tried it yet, but i would try with:

OVERPASS_PLANET_URL=file:///C:\file\path\to\sample.osm.bz2
Franky1 commented 3 years ago

My previous comment was not correct. The URL has to be relative to the container, not the host. The following docker-compose file works with the file:/// prefix. I downloaded bayern-latest.osm.bz2 and put it into the subfolder ./overpass_db and ran docker compose up

version: "3"

services:
  db:
    image: wiktorn/overpass-api
    container_name: overpass_bayern
    ports:
      - "12345:80"
    volumes:
      # mounts local subfolder into container
      - ./overpass_db:/db
    restart: unless-stopped
    environment:
      OVERPASS_META: "no"
      OVERPASS_MODE: "init"
      OVERPASS_PLANET_URL: "file:///db/bayern-latest.osm.bz2"
      # OVERPASS_PLANET_URL: "http://download.geofabrik.de/europe/germany/bayern-latest.osm.bz2"
      OVERPASS_DIFF_URL: "http://download.geofabrik.de/europe/germany/bayern-updates/"
      OVERPASS_RULES_LOAD: 10
      OVERPASS_UPDATE_SLEEP: 3600
pedrocamargo commented 3 years ago

I guess this is not really an issue and the instructions above work perfectly . Thanks for the help, @Franky1

wiktorn commented 3 years ago

I'm closing this issue then.