A few fixes to containers and apps, also added remove app

This commit is contained in:
2026-01-01 17:39:49 +01:00
parent 0439ee7889
commit 4f7376b9b0
9 changed files with 123 additions and 57 deletions
+11
View File
@@ -72,3 +72,14 @@ export async function setEnv(appId: string, variables: EnvVariable[]) {
);
});
}
export async function removeApp(appId: string) {
const nodes = await getNodes();
nodes.forEach(async (n) => {
await axios.delete(`http://${n.ip}:3000/api/applications`, {
params: { appId },
headers: { Authorization: `ApiKey ${n.key}` },
});
});
}
+1 -1
View File
@@ -35,7 +35,7 @@ export async function getContainerStats(
headers: { Authorization: `ApiKey ${n.key}` },
params: { containerId },
})
).data
).data?.stats
)
)
).find((s) => s);
+8
View File
@@ -164,3 +164,11 @@ export async function setEnv(appId: string, variables: EnvVariable[]) {
}
});
}
export async function removeApp(appId: string) {
const imageTag = `dockship/${appId}:latest`;
const image = docker.getImage(imageTag);
await image.remove();
const appPath = path.join(DATA_DIR, appId);
fs.rmSync(appPath, { recursive: true });
}
+9 -1
View File
@@ -15,7 +15,15 @@ export async function getDocker() {
export async function getContainerStats(
containerId: string
): Promise<SimpleStats | undefined> {
const stats = await docker.getContainer(containerId).stats({ stream: false });
const container = docker.getContainer(containerId);
const data = await container.inspect();
if (!data.State.Running) {
return;
}
const stats = await container.stats({ stream: false });
return {
cpu: CPUusage(stats),