@@ -298,10 +298,10 @@ export class DockerService {
298298 const OSM_PBF_URL = 'https://download.geofabrik.de/north-america/us-pacific-latest.osm.pbf' ; // Download US Pacific sub-region for initial import
299299
300300 const IMPORT_FILE = 'region.osm.pbf' ;
301- const IMPORT_FILE_PATH = `${ DockerService . NOMAD_STORAGE_ABS_PATH } /osm/${ IMPORT_FILE } ` ;
301+ const IMPORT_FILE_PATH = `${ DockerService . NOMAD_STORAGE_ABS_PATH } /osm/${ IMPORT_FILE } ` ; // We only want to use the full abs path here because we need to pass it to the Docker container config
302302 const IMPORT_BIND = `${ IMPORT_FILE_PATH } :/data/${ IMPORT_FILE } :rw` ;
303303
304- const LOG_PATH = `${ DockerService . NOMAD_STORAGE_ABS_PATH } /logs/${ DockerService . OPENSTREETMAP_IMPORT_SERVICE_NAME } .log` ;
304+ const LOG_PATH = `/logs/${ DockerService . OPENSTREETMAP_IMPORT_SERVICE_NAME } .log` ;
305305 const disk = drive . use ( 'fs' ) ;
306306
307307 this . _broadcast ( DockerService . OPENSTREETMAP_IMPORT_SERVICE_NAME , 'preinstall' , `Running pre-install actions for OpenStreetMap Tile Server...` ) ;
@@ -310,16 +310,16 @@ export class DockerService {
310310 this . _broadcast ( DockerService . OPENSTREETMAP_IMPORT_SERVICE_NAME , 'preinstall' , 'Ensuring OSM directory permissions are set correctly...' ) ;
311311
312312 // Ensure directories exist
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 } ) ;
313+ await fs . promises . mkdir ( `/osm/db` , { recursive : true } ) ;
314+ await fs . promises . mkdir ( `/osm/tiles` , { recursive : true } ) ;
315315
316316 // 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 ) ;
317+ await chmodRecursive ( `/osm/db` , 0o755 , 0o755 ) ;
318+ await chownRecursive ( `/osm/db` , 1000 , 1000 ) ;
319319
320320 // 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 ) ;
321+ await chmodRecursive ( `/osm/tiles` , 0o755 , 0o755 ) ;
322+ await chownRecursive ( `/osm/tiles` , 1000 , 1000 ) ;
323323
324324 // If the initial import file already exists, delete it so we can ensure it is a good download
325325 const fileExists = await disk . exists ( IMPORT_FILE_PATH ) ;
@@ -331,7 +331,7 @@ export class DockerService {
331331 const response = await axios . get ( OSM_PBF_URL , {
332332 responseType : 'stream' ,
333333 } ) ;
334- await disk . putStream ( IMPORT_FILE_PATH , response . data ) ;
334+ await disk . putStream ( `/osm/ ${ IMPORT_FILE } ` , response . data ) ;
335335
336336 // Do initial import of OSM data into the tile server DB
337337 // We need to add the initial osm.pbf file as another volume bind so we can import it
@@ -368,11 +368,20 @@ export class DockerService {
368368 const data = await container . wait ( ) ;
369369 logger . debug ( `OpenStreetMap data import result: ${ JSON . stringify ( data ) } ` ) ;
370370
371- if ( data . StatusCode !== 0 ) {
372- throw new Error ( `OpenStreetMap data import failed with status code ${ data . StatusCode } . Check the log file at ${ LOG_PATH } for details.` ) ;
373- }
374-
371+ const statusCode = data . StatusCode ;
375372 await container . remove ( ) ;
373+
374+ // Set perms again to ensure they are correct after import process
375+ await chmodRecursive ( `/osm/db` , 0o755 , 0o755 ) ;
376+ await chownRecursive ( `/osm/db` , 1000 , 1000 ) ;
377+
378+ await chmodRecursive ( `/osm/tiles` , 0o755 , 0o755 ) ;
379+ await chownRecursive ( `/osm/tiles` , 1000 , 1000 ) ;
380+
381+
382+ if ( statusCode !== 0 ) {
383+ throw new Error ( `OpenStreetMap data import failed with status code ${ statusCode } . Check the log file at ${ LOG_PATH } for details.` ) ;
384+ }
376385 }
377386
378387 private _broadcast ( service : string , status : string , message : string ) {
0 commit comments