mirror of
https://github.com/Crosstalk-Solutions/project-nomad.git
synced 2026-04-05 08:16:16 +02:00
fix(OSM): use absolute host paths
This commit is contained in:
parent
4e1377554a
commit
85e6b84e32
|
|
@ -18,6 +18,7 @@ export class DockerService {
|
||||||
public static OPENSTREETMAP_IMPORT_SERVICE_NAME = 'nomad_openstreetmap_import';
|
public static OPENSTREETMAP_IMPORT_SERVICE_NAME = 'nomad_openstreetmap_import';
|
||||||
public static OLLAMA_SERVICE_NAME = 'nomad_ollama';
|
public static OLLAMA_SERVICE_NAME = 'nomad_ollama';
|
||||||
public static OPEN_WEBUI_SERVICE_NAME = 'nomad_open_webui';
|
public static OPEN_WEBUI_SERVICE_NAME = 'nomad_open_webui';
|
||||||
|
public static NOMAD_STORAGE_ABS_PATH = '/opt/project-nomad/storage';
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.docker = new Docker({ socketPath: '/var/run/docker.sock' });
|
this.docker = new Docker({ socketPath: '/var/run/docker.sock' });
|
||||||
|
|
@ -295,11 +296,12 @@ export class DockerService {
|
||||||
*/
|
*/
|
||||||
private async _runPreinstallActions__OpenStreetMap(image: string, containerConfig: any): Promise<void> {
|
private async _runPreinstallActions__OpenStreetMap(image: string, containerConfig: any): Promise<void> {
|
||||||
const OSM_PBF_URL = 'https://download.geofabrik.de/north-america/us-pacific-latest.osm.pbf'; // Download US Pacific sub-region for initial import
|
const OSM_PBF_URL = 'https://download.geofabrik.de/north-america/us-pacific-latest.osm.pbf'; // Download US Pacific sub-region for initial import
|
||||||
|
|
||||||
const IMPORT_FILE = 'region.osm.pbf';
|
const IMPORT_FILE = 'region.osm.pbf';
|
||||||
const PATH = `/osm/${IMPORT_FILE}`;
|
const IMPORT_FILE_PATH = `${DockerService.NOMAD_STORAGE_ABS_PATH}/osm/${IMPORT_FILE}`;
|
||||||
const HOST_PATH = `/opt/project-nomad/storage${PATH}`;
|
const IMPORT_BIND = `${IMPORT_FILE_PATH}:/data/${IMPORT_FILE}:rw`;
|
||||||
const IMPORT_BIND = `${HOST_PATH}:/data/${IMPORT_FILE}:rw`;
|
|
||||||
const LOG_PATH = `/logs/${DockerService.OPENSTREETMAP_IMPORT_SERVICE_NAME}.log`;
|
const LOG_PATH = `${DockerService.NOMAD_STORAGE_ABS_PATH}/logs/${DockerService.OPENSTREETMAP_IMPORT_SERVICE_NAME}.log`;
|
||||||
const disk = drive.use('fs');
|
const disk = drive.use('fs');
|
||||||
|
|
||||||
this._broadcast(DockerService.OPENSTREETMAP_IMPORT_SERVICE_NAME, 'preinstall', `Running pre-install actions for OpenStreetMap Tile Server...`);
|
this._broadcast(DockerService.OPENSTREETMAP_IMPORT_SERVICE_NAME, 'preinstall', `Running pre-install actions for OpenStreetMap Tile Server...`);
|
||||||
|
|
@ -308,27 +310,28 @@ export class DockerService {
|
||||||
this._broadcast(DockerService.OPENSTREETMAP_IMPORT_SERVICE_NAME, 'preinstall', 'Ensuring OSM directory permissions are set correctly...');
|
this._broadcast(DockerService.OPENSTREETMAP_IMPORT_SERVICE_NAME, 'preinstall', 'Ensuring OSM directory permissions are set correctly...');
|
||||||
|
|
||||||
// Ensure directories exist
|
// Ensure directories exist
|
||||||
await fs.promises.mkdir('/osm/db', { recursive: true });
|
await fs.promises.mkdir(`${DockerService.NOMAD_STORAGE_ABS_PATH}/osm/db`, { recursive: true });
|
||||||
await fs.promises.mkdir('/osm/tiles', { recursive: true });
|
await fs.promises.mkdir(`${DockerService.NOMAD_STORAGE_ABS_PATH}/osm/tiles`, { recursive: true });
|
||||||
|
|
||||||
await chmodRecursive('/osm/db', 0o755, 0o755); // Must be able to read directories and read/write files inside
|
// Must be able to read directories and read/write files inside
|
||||||
await chownRecursive('/osm/db', 1000, 1000);
|
await chmodRecursive(`${DockerService.NOMAD_STORAGE_ABS_PATH}/osm/db`, 0o755, 0o755);
|
||||||
|
await chownRecursive(`${DockerService.NOMAD_STORAGE_ABS_PATH}/osm/db`, 1000, 1000);
|
||||||
await chmodRecursive('/osm/tiles', 0o755, 0o755); // Must be able to read directories and read/write files inside
|
|
||||||
await chownRecursive('/osm/tiles', 1000, 1000);
|
|
||||||
|
|
||||||
|
// Must be able to read directories and read/write files inside
|
||||||
|
await chmodRecursive(`${DockerService.NOMAD_STORAGE_ABS_PATH}/osm/tiles`, 0o755, 0o755);
|
||||||
|
await chownRecursive(`${DockerService.NOMAD_STORAGE_ABS_PATH}/osm/tiles`, 1000, 1000);
|
||||||
|
|
||||||
// If the initial import file already exists, delete it so we can ensure it is a good download
|
// If the initial import file already exists, delete it so we can ensure it is a good download
|
||||||
const fileExists = await disk.exists(PATH);
|
const fileExists = await disk.exists(IMPORT_FILE_PATH);
|
||||||
if (fileExists) {
|
if (fileExists) {
|
||||||
await disk.delete(PATH);
|
await disk.delete(IMPORT_FILE_PATH);
|
||||||
}
|
}
|
||||||
|
|
||||||
this._broadcast(DockerService.OPENSTREETMAP_IMPORT_SERVICE_NAME, 'preinstall', `Downloading OpenStreetMap PBF file from ${OSM_PBF_URL}. This may take some time...`);
|
this._broadcast(DockerService.OPENSTREETMAP_IMPORT_SERVICE_NAME, 'preinstall', `Downloading OpenStreetMap PBF file from ${OSM_PBF_URL}. This may take some time...`);
|
||||||
const response = await axios.get(OSM_PBF_URL, {
|
const response = await axios.get(OSM_PBF_URL, {
|
||||||
responseType: 'arraybuffer',
|
responseType: 'stream',
|
||||||
});
|
});
|
||||||
await disk.put(PATH, response.data);
|
await disk.putStream(IMPORT_FILE_PATH, response.data);
|
||||||
|
|
||||||
// Do initial import of OSM data into the tile server DB
|
// Do initial import of OSM data into the tile server DB
|
||||||
// We need to add the initial osm.pbf file as another volume bind so we can import it
|
// We need to add the initial osm.pbf file as another volume bind so we can import it
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ export default class ServiceSeeder extends BaseSeeder {
|
||||||
container_config: JSON.stringify({
|
container_config: JSON.stringify({
|
||||||
HostConfig: {
|
HostConfig: {
|
||||||
RestartPolicy: { Name: 'unless-stopped' },
|
RestartPolicy: { Name: 'unless-stopped' },
|
||||||
Binds: ['/zim:/data'],
|
Binds: [`${DockerService.NOMAD_STORAGE_ABS_PATH}/zim:/data`],
|
||||||
PortBindings: { '8080/tcp': [{ HostPort: '8090' }] }
|
PortBindings: { '8080/tcp': [{ HostPort: '8090' }] }
|
||||||
},
|
},
|
||||||
ExposedPorts: { '8080/tcp': {} }
|
ExposedPorts: { '8080/tcp': {} }
|
||||||
|
|
@ -30,8 +30,8 @@ export default class ServiceSeeder extends BaseSeeder {
|
||||||
HostConfig: {
|
HostConfig: {
|
||||||
RestartPolicy: { Name: 'unless-stopped' },
|
RestartPolicy: { Name: 'unless-stopped' },
|
||||||
Binds: [
|
Binds: [
|
||||||
'/osm/db:/data/database:rw',
|
`${DockerService.NOMAD_STORAGE_ABS_PATH}/osm/db:/data/database:rw`,
|
||||||
'/osm/tiles:/data/tiles:rw'
|
`${DockerService.NOMAD_STORAGE_ABS_PATH}/osm/tiles:/data/tiles:rw`
|
||||||
],
|
],
|
||||||
PortBindings: { '80/tcp': [{ HostPort: '9000' }] }
|
PortBindings: { '80/tcp': [{ HostPort: '9000' }] }
|
||||||
}
|
}
|
||||||
|
|
@ -48,7 +48,7 @@ export default class ServiceSeeder extends BaseSeeder {
|
||||||
container_config: JSON.stringify({
|
container_config: JSON.stringify({
|
||||||
HostConfig: {
|
HostConfig: {
|
||||||
RestartPolicy: { Name: 'unless-stopped' },
|
RestartPolicy: { Name: 'unless-stopped' },
|
||||||
Binds: ['/ollama:/root/.ollama'],
|
Binds: [`${DockerService.NOMAD_STORAGE_ABS_PATH}/ollama:/root/.ollama`],
|
||||||
PortBindings: { '11434/tcp': [{ HostPort: '11434' }] }
|
PortBindings: { '11434/tcp': [{ HostPort: '11434' }] }
|
||||||
},
|
},
|
||||||
ExposedPorts: { '11434/tcp': {} }
|
ExposedPorts: { '11434/tcp': {} }
|
||||||
|
|
@ -66,7 +66,7 @@ export default class ServiceSeeder extends BaseSeeder {
|
||||||
HostConfig: {
|
HostConfig: {
|
||||||
RestartPolicy: { Name: 'unless-stopped' },
|
RestartPolicy: { Name: 'unless-stopped' },
|
||||||
NetworkMode: 'host',
|
NetworkMode: 'host',
|
||||||
Binds: ['/open-webui:/app/backend/data']
|
Binds: [`${DockerService.NOMAD_STORAGE_ABS_PATH}/open-webui:/app/backend/data`]
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
ui_location: '3000',
|
ui_location: '3000',
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user