feat: implement custom Docker image update functionality in server settings

- Added support for pulling and updating the server with a custom Docker image URL.
- Introduced new state management for custom updates in the UpdateServer component.
- Updated API to handle optional image URL input for server updates.
This commit is contained in:
ayham291
2025-06-01 23:49:25 +02:00
parent 98aabd7bd8
commit 6642941f62
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(