fix: isolate platform service data dirs
This commit is contained in:
@@ -103,6 +103,16 @@ export abstract class BasePlatformServiceProvider implements IPlatformServicePro
|
|||||||
return `onebox-${this.type}`;
|
return `onebox-${this.type}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the host data directory for a platform service.
|
||||||
|
*/
|
||||||
|
protected getPlatformDataDir(serviceDirectoryArg: string): string {
|
||||||
|
const configuredDataDir = this.oneboxRef.database.getSetting('dataDir');
|
||||||
|
const baseDataDir = configuredDataDir ||
|
||||||
|
(Deno.env.get('ONEBOX_DEV') === 'true' ? './.nogit/platform-data' : '/var/lib/onebox');
|
||||||
|
return `${baseDataDir.replace(/\/+$/, '')}/${serviceDirectoryArg}`;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate a resource name from a user service name
|
* Generate a resource name from a user service name
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ export class ClickHouseProvider extends BasePlatformServiceProvider {
|
|||||||
return {
|
return {
|
||||||
image: 'clickhouse/clickhouse-server:latest',
|
image: 'clickhouse/clickhouse-server:latest',
|
||||||
port: 8123, // HTTP interface
|
port: 8123, // HTTP interface
|
||||||
volumes: ['/var/lib/onebox/clickhouse:/var/lib/clickhouse'],
|
volumes: [`${this.getPlatformDataDir('clickhouse')}:/var/lib/clickhouse`],
|
||||||
environment: {
|
environment: {
|
||||||
CLICKHOUSE_DB: 'default',
|
CLICKHOUSE_DB: 'default',
|
||||||
// Password will be generated and stored encrypted
|
// Password will be generated and stored encrypted
|
||||||
@@ -53,7 +53,7 @@ export class ClickHouseProvider extends BasePlatformServiceProvider {
|
|||||||
async deployContainer(): Promise<string> {
|
async deployContainer(): Promise<string> {
|
||||||
const config = this.getDefaultConfig();
|
const config = this.getDefaultConfig();
|
||||||
const containerName = this.getContainerName();
|
const containerName = this.getContainerName();
|
||||||
const dataDir = '/var/lib/onebox/clickhouse';
|
const dataDir = this.getPlatformDataDir('clickhouse');
|
||||||
|
|
||||||
logger.info(`Deploying ClickHouse platform service as ${containerName}...`);
|
logger.info(`Deploying ClickHouse platform service as ${containerName}...`);
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ export class MariaDBProvider extends BasePlatformServiceProvider {
|
|||||||
return {
|
return {
|
||||||
image: 'mariadb:11',
|
image: 'mariadb:11',
|
||||||
port: 3306,
|
port: 3306,
|
||||||
volumes: ['/var/lib/onebox/mariadb:/var/lib/mysql'],
|
volumes: [`${this.getPlatformDataDir('mariadb')}:/var/lib/mysql`],
|
||||||
environment: {
|
environment: {
|
||||||
MARIADB_ROOT_PASSWORD: '',
|
MARIADB_ROOT_PASSWORD: '',
|
||||||
// Password will be generated and stored encrypted
|
// Password will be generated and stored encrypted
|
||||||
@@ -52,7 +52,7 @@ export class MariaDBProvider extends BasePlatformServiceProvider {
|
|||||||
async deployContainer(): Promise<string> {
|
async deployContainer(): Promise<string> {
|
||||||
const config = this.getDefaultConfig();
|
const config = this.getDefaultConfig();
|
||||||
const containerName = this.getContainerName();
|
const containerName = this.getContainerName();
|
||||||
const dataDir = '/var/lib/onebox/mariadb';
|
const dataDir = this.getPlatformDataDir('mariadb');
|
||||||
|
|
||||||
logger.info(`Deploying MariaDB platform service as ${containerName}...`);
|
logger.info(`Deploying MariaDB platform service as ${containerName}...`);
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ export class MinioProvider extends BasePlatformServiceProvider {
|
|||||||
return {
|
return {
|
||||||
image: 'minio/minio:latest',
|
image: 'minio/minio:latest',
|
||||||
port: 9000,
|
port: 9000,
|
||||||
volumes: ['/var/lib/onebox/minio:/data'],
|
volumes: [`${this.getPlatformDataDir('minio')}:/data`],
|
||||||
command: 'server /data --console-address :9001',
|
command: 'server /data --console-address :9001',
|
||||||
environment: {
|
environment: {
|
||||||
MINIO_ROOT_USER: 'admin',
|
MINIO_ROOT_USER: 'admin',
|
||||||
@@ -57,7 +57,7 @@ export class MinioProvider extends BasePlatformServiceProvider {
|
|||||||
async deployContainer(): Promise<string> {
|
async deployContainer(): Promise<string> {
|
||||||
const config = this.getDefaultConfig();
|
const config = this.getDefaultConfig();
|
||||||
const containerName = this.getContainerName();
|
const containerName = this.getContainerName();
|
||||||
const dataDir = '/var/lib/onebox/minio';
|
const dataDir = this.getPlatformDataDir('minio');
|
||||||
|
|
||||||
logger.info(`Deploying MinIO platform service as ${containerName}...`);
|
logger.info(`Deploying MinIO platform service as ${containerName}...`);
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ export class MongoDBProvider extends BasePlatformServiceProvider {
|
|||||||
return {
|
return {
|
||||||
image: 'mongo:4.4',
|
image: 'mongo:4.4',
|
||||||
port: 27017,
|
port: 27017,
|
||||||
volumes: ['/var/lib/onebox/mongodb:/data/db'],
|
volumes: [`${this.getPlatformDataDir('mongodb')}:/data/db`],
|
||||||
environment: {
|
environment: {
|
||||||
MONGO_INITDB_ROOT_USERNAME: 'admin',
|
MONGO_INITDB_ROOT_USERNAME: 'admin',
|
||||||
// Password will be generated and stored encrypted
|
// Password will be generated and stored encrypted
|
||||||
@@ -52,7 +52,7 @@ export class MongoDBProvider extends BasePlatformServiceProvider {
|
|||||||
async deployContainer(): Promise<string> {
|
async deployContainer(): Promise<string> {
|
||||||
const config = this.getDefaultConfig();
|
const config = this.getDefaultConfig();
|
||||||
const containerName = this.getContainerName();
|
const containerName = this.getContainerName();
|
||||||
const dataDir = '/var/lib/onebox/mongodb';
|
const dataDir = this.getPlatformDataDir('mongodb');
|
||||||
|
|
||||||
logger.info(`Deploying MongoDB platform service as ${containerName}...`);
|
logger.info(`Deploying MongoDB platform service as ${containerName}...`);
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ export class RedisProvider extends BasePlatformServiceProvider {
|
|||||||
return {
|
return {
|
||||||
image: 'redis:7-alpine',
|
image: 'redis:7-alpine',
|
||||||
port: 6379,
|
port: 6379,
|
||||||
volumes: ['/var/lib/onebox/redis:/data'],
|
volumes: [`${this.getPlatformDataDir('redis')}:/data`],
|
||||||
environment: {},
|
environment: {},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -48,7 +48,7 @@ export class RedisProvider extends BasePlatformServiceProvider {
|
|||||||
async deployContainer(): Promise<string> {
|
async deployContainer(): Promise<string> {
|
||||||
const config = this.getDefaultConfig();
|
const config = this.getDefaultConfig();
|
||||||
const containerName = this.getContainerName();
|
const containerName = this.getContainerName();
|
||||||
const dataDir = '/var/lib/onebox/redis';
|
const dataDir = this.getPlatformDataDir('redis');
|
||||||
|
|
||||||
logger.info(`Deploying Redis platform service as ${containerName}...`);
|
logger.info(`Deploying Redis platform service as ${containerName}...`);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user