mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
fix: select the right image from sourcetype (#109)
This commit is contained in:
@@ -65,8 +65,6 @@ export const mechanizeDockerContainer = async (
|
|||||||
appName,
|
appName,
|
||||||
env,
|
env,
|
||||||
mounts,
|
mounts,
|
||||||
sourceType,
|
|
||||||
dockerImage,
|
|
||||||
cpuLimit,
|
cpuLimit,
|
||||||
memoryLimit,
|
memoryLimit,
|
||||||
memoryReservation,
|
memoryReservation,
|
||||||
@@ -99,27 +97,11 @@ export const mechanizeDockerContainer = async (
|
|||||||
const filesMount = generateFileMounts(appName, mounts);
|
const filesMount = generateFileMounts(appName, mounts);
|
||||||
const envVariables = prepareEnvironmentVariables(env);
|
const envVariables = prepareEnvironmentVariables(env);
|
||||||
|
|
||||||
const registry = application.registry;
|
const image = getImageName(application);
|
||||||
|
const authConfig = getAuthConfig(application);
|
||||||
let image =
|
|
||||||
sourceType === "docker"
|
|
||||||
? dockerImage || "ERROR-NO-IMAGE-PROVIDED"
|
|
||||||
: `${appName}:latest`;
|
|
||||||
|
|
||||||
if (registry) {
|
|
||||||
image = `${registry.registryUrl}/${appName}`;
|
|
||||||
|
|
||||||
if (registry.imagePrefix) {
|
|
||||||
image = `${registry.registryUrl}/${registry.imagePrefix}/${appName}`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const settings: CreateServiceOptions = {
|
const settings: CreateServiceOptions = {
|
||||||
authconfig: {
|
authconfig: authConfig,
|
||||||
password: registry?.password || "",
|
|
||||||
username: registry?.username || "",
|
|
||||||
serveraddress: registry?.registryUrl || "",
|
|
||||||
},
|
|
||||||
Name: appName,
|
Name: appName,
|
||||||
TaskTemplate: {
|
TaskTemplate: {
|
||||||
ContainerSpec: {
|
ContainerSpec: {
|
||||||
@@ -170,3 +152,39 @@ export const mechanizeDockerContainer = async (
|
|||||||
await docker.createService(settings);
|
await docker.createService(settings);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const getImageName = (application: ApplicationNested) => {
|
||||||
|
const { appName, sourceType, dockerImage, registry } = application;
|
||||||
|
|
||||||
|
if (sourceType === "docker") {
|
||||||
|
return dockerImage || "ERROR-NO-IMAGE-PROVIDED";
|
||||||
|
}
|
||||||
|
|
||||||
|
const registryUrl = registry?.registryUrl || "";
|
||||||
|
const imagePrefix = registry?.imagePrefix ? `${registry.imagePrefix}/` : "";
|
||||||
|
return registry
|
||||||
|
? `${registryUrl}/${imagePrefix}${appName}`
|
||||||
|
: `${appName}:latest`;
|
||||||
|
};
|
||||||
|
|
||||||
|
const getAuthConfig = (application: ApplicationNested) => {
|
||||||
|
const { registry, username, password, sourceType } = application;
|
||||||
|
|
||||||
|
if (sourceType === "docker") {
|
||||||
|
if (username && password) {
|
||||||
|
return {
|
||||||
|
password,
|
||||||
|
username,
|
||||||
|
serveraddress: "https://index.docker.io/v1/",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
} else if (registry) {
|
||||||
|
return {
|
||||||
|
password: registry.password,
|
||||||
|
username: registry.username,
|
||||||
|
serveraddress: registry.registryUrl,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return undefined;
|
||||||
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user