This commit is contained in:
Ayham
2025-06-22 18:25:41 +02:00
committed by GitHub
4 changed files with 262 additions and 129 deletions

View File

@@ -21,12 +21,13 @@ export const getDokployImageTag = () => {
return process.env.RELEASE_TAG || "latest";
};
export const getDokployImage = () => {
return `dokploy/dokploy:${getDokployImageTag()}`;
export const getDokployImage = (customImage?: string) => {
return customImage || `dokploy/dokploy:${getDokployImageTag()}`;
};
export const pullLatestRelease = async () => {
const stream = await docker.pull(getDokployImage());
export const pullRelease = async (customImage?: string) => {
const imageToPull = getDokployImage(customImage);
const stream = await docker.pull(imageToPull);
await new Promise((resolve, reject) => {
docker.modem.followProgress(stream, (err, res) =>
err ? reject(err) : resolve(res),
@@ -34,6 +35,17 @@ export const pullLatestRelease = async () => {
});
};
/** Pulls a custom Docker image and returns whether it was successful */
export const pullCustomImage = async (imageUrl: string): Promise<boolean> => {
try {
await pullRelease(imageUrl);
return true;
} catch (error) {
console.error("Error pulling custom image:", error);
return false;
}
};
/** Returns Dokploy docker service image digest */
export const getServiceImageDigest = async () => {
const { stdout } = await execAsync(