@@ -18,6 +18,7 @@ export class DockerService {
1818 public static OPENSTREETMAP_IMPORT_SERVICE_NAME = 'nomad_openstreetmap_import' ;
1919 public static OLLAMA_SERVICE_NAME = 'nomad_ollama' ;
2020 public static OPEN_WEBUI_SERVICE_NAME = 'nomad_open_webui' ;
21+ public static NOMAD_STORAGE_ABS_PATH = '/opt/project-nomad/storage' ;
2122
2223 constructor ( ) {
2324 this . docker = new Docker ( { socketPath : '/var/run/docker.sock' } ) ;
@@ -295,11 +296,12 @@ export class DockerService {
295296 */
296297 private async _runPreinstallActions__OpenStreetMap ( image : string , containerConfig : any ) : Promise < void > {
297298 const OSM_PBF_URL = 'https://download.geofabrik.de/north-america/us-pacific-latest.osm.pbf' ; // Download US Pacific sub-region for initial import
299+
298300 const IMPORT_FILE = 'region.osm.pbf' ;
299- const PATH = `/osm/${ IMPORT_FILE } ` ;
300- const HOST_PATH = `/opt/project-nomad/storage ${ PATH } ` ;
301- const IMPORT_BIND = ` ${ HOST_PATH } :/data/ ${ IMPORT_FILE } :rw` ;
302- const LOG_PATH = `/logs/${ DockerService . OPENSTREETMAP_IMPORT_SERVICE_NAME } .log` ;
301+ const IMPORT_FILE_PATH = `${ DockerService . NOMAD_STORAGE_ABS_PATH } /osm/${ IMPORT_FILE } ` ;
302+ const IMPORT_BIND = `${ IMPORT_FILE_PATH } :/data/ ${ IMPORT_FILE } :rw ` ;
303+
304+ const LOG_PATH = `${ DockerService . NOMAD_STORAGE_ABS_PATH } /logs/${ DockerService . OPENSTREETMAP_IMPORT_SERVICE_NAME } .log` ;
303305 const disk = drive . use ( 'fs' ) ;
304306
305307 this . _broadcast ( DockerService . OPENSTREETMAP_IMPORT_SERVICE_NAME , 'preinstall' , `Running pre-install actions for OpenStreetMap Tile Server...` ) ;
@@ -308,27 +310,28 @@ export class DockerService {
308310 this . _broadcast ( DockerService . OPENSTREETMAP_IMPORT_SERVICE_NAME , 'preinstall' , 'Ensuring OSM directory permissions are set correctly...' ) ;
309311
310312 // Ensure directories exist
311- await fs . promises . mkdir ( ' /osm/db' , { recursive : true } ) ;
312- await fs . promises . mkdir ( ' /osm/tiles' , { recursive : true } ) ;
313+ await fs . promises . mkdir ( ` ${ DockerService . NOMAD_STORAGE_ABS_PATH } /osm/db` , { recursive : true } ) ;
314+ await fs . promises . mkdir ( ` ${ DockerService . NOMAD_STORAGE_ABS_PATH } /osm/tiles` , { recursive : true } ) ;
313315
314- await chmodRecursive ( '/osm/db' , 0o755 , 0o755 ) ; // Must be able to read directories and read/write files inside
315- await chownRecursive ( '/osm/db' , 1000 , 1000 ) ;
316-
317- await chmodRecursive ( '/osm/tiles' , 0o755 , 0o755 ) ; // Must be able to read directories and read/write files inside
318- await chownRecursive ( '/osm/tiles' , 1000 , 1000 ) ;
316+ // Must be able to read directories and read/write files inside
317+ await chmodRecursive ( `${ DockerService . NOMAD_STORAGE_ABS_PATH } /osm/db` , 0o755 , 0o755 ) ;
318+ await chownRecursive ( `${ DockerService . NOMAD_STORAGE_ABS_PATH } /osm/db` , 1000 , 1000 ) ;
319319
320+ // Must be able to read directories and read/write files inside
321+ await chmodRecursive ( `${ DockerService . NOMAD_STORAGE_ABS_PATH } /osm/tiles` , 0o755 , 0o755 ) ;
322+ await chownRecursive ( `${ DockerService . NOMAD_STORAGE_ABS_PATH } /osm/tiles` , 1000 , 1000 ) ;
320323
321324 // If the initial import file already exists, delete it so we can ensure it is a good download
322- const fileExists = await disk . exists ( PATH ) ;
325+ const fileExists = await disk . exists ( IMPORT_FILE_PATH ) ;
323326 if ( fileExists ) {
324- await disk . delete ( PATH ) ;
327+ await disk . delete ( IMPORT_FILE_PATH ) ;
325328 }
326329
327330 this . _broadcast ( DockerService . OPENSTREETMAP_IMPORT_SERVICE_NAME , 'preinstall' , `Downloading OpenStreetMap PBF file from ${ OSM_PBF_URL } . This may take some time...` ) ;
328331 const response = await axios . get ( OSM_PBF_URL , {
329- responseType : 'arraybuffer ' ,
332+ responseType : 'stream ' ,
330333 } ) ;
331- await disk . put ( PATH , response . data ) ;
334+ await disk . putStream ( IMPORT_FILE_PATH , response . data ) ;
332335
333336 // Do initial import of OSM data into the tile server DB
334337 // We need to add the initial osm.pbf file as another volume bind so we can import it
0 commit comments