fix(registry): add image tag resolution correctly when using cluster

This commit is contained in:
Mauricio Siu
2024-11-02 14:17:21 -06:00
parent fae97b1817
commit 766a25ccad
6 changed files with 79 additions and 37 deletions

View File

@@ -1,7 +1,8 @@
import { createWriteStream } from "node:fs";
import { join } from "node:path";
import type { InferResultType } from "@dokploy/server/types/with";
import type { CreateServiceOptions } from "dockerode";
import { uploadImage } from "../cluster/upload";
import { uploadImage, uploadImageRemoteCommand } from "../cluster/upload";
import {
calculateResources,
generateBindMounts,
@@ -69,19 +70,30 @@ export const getBuildCommand = (
application: ApplicationNested,
logPath: string,
) => {
const { buildType } = application;
let command = "";
const { buildType, registry } = application;
switch (buildType) {
case "nixpacks":
return getNixpacksCommand(application, logPath);
command = getNixpacksCommand(application, logPath);
break;
case "heroku_buildpacks":
return getHerokuCommand(application, logPath);
command = getHerokuCommand(application, logPath);
break;
case "paketo_buildpacks":
return getPaketoCommand(application, logPath);
command = getPaketoCommand(application, logPath);
break;
case "static":
return getStaticCommand(application, logPath);
command = getStaticCommand(application, logPath);
break;
case "dockerfile":
return getDockerCommand(application, logPath);
command = getDockerCommand(application, logPath);
break;
}
if (registry) {
command += uploadImageRemoteCommand(application, logPath);
}
return command;
};
export const mechanizeDockerContainer = async (
@@ -186,11 +198,11 @@ const getImageName = (application: ApplicationNested) => {
return dockerImage || "ERROR-NO-IMAGE-PROVIDED";
}
const registryUrl = registry?.registryUrl || "";
const imagePrefix = registry?.imagePrefix ? `${registry.imagePrefix}/` : "";
return registry
? `${registryUrl}/${imagePrefix}${appName}`
: `${appName}:latest`;
if (registry) {
return join(registry.registryUrl, registry.imagePrefix || "", appName);
}
return `${appName}:latest`;
};
const getAuthConfig = (application: ApplicationNested) => {