mirror of
https://github.com/Dokploy/dokploy.git
synced 2026-07-01 12:05:23 +02:00
feat: add option to enable namespaces
This commit is contained in:
@@ -8,8 +8,27 @@ import {
|
||||
generateVolumeMounts,
|
||||
prepareEnvironmentVariables,
|
||||
} from "../docker/utils";
|
||||
import { execAsync, execAsyncRemote } from "../process/execAsync";
|
||||
import { getRemoteDocker } from "../servers/remote-docker";
|
||||
|
||||
const getServerArchitecture = async (
|
||||
serverId?: string | null,
|
||||
): Promise<string> => {
|
||||
if (!serverId) {
|
||||
const { stdout } = await execAsync("uname -m");
|
||||
return stdout.trim();
|
||||
}
|
||||
const { stdout } = await execAsyncRemote(serverId, "uname -m");
|
||||
return stdout.trim();
|
||||
};
|
||||
|
||||
const getLibsqlImage = (arch: string): string => {
|
||||
if (arch === "aarch64" || arch === "arm64") {
|
||||
return "ghcr.io/tursodatabase/libsql-server:latest-arm";
|
||||
}
|
||||
return "ghcr.io/tursodatabase/libsql-server:latest";
|
||||
};
|
||||
|
||||
export type LibsqlNested = InferResultType<
|
||||
"libsql",
|
||||
{ mounts: true; environment: { with: { project: true } } }
|
||||
@@ -20,6 +39,7 @@ export const buildLibsql = async (libsql: LibsqlNested) => {
|
||||
env,
|
||||
externalPort,
|
||||
externalGRPCPort,
|
||||
externalAdminPort,
|
||||
dockerImage,
|
||||
memoryLimit,
|
||||
memoryReservation,
|
||||
@@ -31,8 +51,16 @@ export const buildLibsql = async (libsql: LibsqlNested) => {
|
||||
cpuReservation,
|
||||
command,
|
||||
mounts,
|
||||
serverId,
|
||||
enableNamespaces,
|
||||
} = libsql;
|
||||
|
||||
let finalDockerImage = dockerImage;
|
||||
if (dockerImage === "ghcr.io/tursodatabase/libsql-server:latest") {
|
||||
const arch = await getServerArchitecture(serverId);
|
||||
finalDockerImage = getLibsqlImage(arch);
|
||||
}
|
||||
|
||||
const basicAuth = Buffer.from(
|
||||
`${databaseUser}:${databasePassword}`,
|
||||
"utf-8",
|
||||
@@ -69,18 +97,25 @@ export const buildLibsql = async (libsql: LibsqlNested) => {
|
||||
|
||||
const docker = await getRemoteDocker(libsql.serverId);
|
||||
|
||||
let finalCommand =
|
||||
command ??
|
||||
"sqld --db-path iku.db --http-listen-addr 0.0.0.0:8080 --grpc-listen-addr 0.0.0.0:5001 --admin-listen-addr 0.0.0.0:5000";
|
||||
if (enableNamespaces) {
|
||||
finalCommand += " --enable-namespaces";
|
||||
}
|
||||
|
||||
const settings: CreateServiceOptions = {
|
||||
Name: appName,
|
||||
TaskTemplate: {
|
||||
ContainerSpec: {
|
||||
HealthCheck,
|
||||
Image: dockerImage,
|
||||
Image: finalDockerImage,
|
||||
Env: envVariables,
|
||||
Mounts: [...volumesMount, ...bindsMount, ...filesMount],
|
||||
...(command
|
||||
...(finalCommand
|
||||
? {
|
||||
Command: ["/bin/sh"],
|
||||
Args: ["-c", command],
|
||||
Args: ["-c", finalCommand],
|
||||
}
|
||||
: {}),
|
||||
Labels,
|
||||
@@ -117,6 +152,16 @@ export const buildLibsql = async (libsql: LibsqlNested) => {
|
||||
} as PortConfig,
|
||||
]
|
||||
: []),
|
||||
...(externalAdminPort
|
||||
? [
|
||||
{
|
||||
Protocol: "tcp",
|
||||
TargetPort: 5000,
|
||||
PublishedPort: externalAdminPort,
|
||||
PublishMode: "host",
|
||||
} as PortConfig,
|
||||
]
|
||||
: []),
|
||||
],
|
||||
},
|
||||
UpdateConfig,
|
||||
|
||||
Reference in New Issue
Block a user