make build work across server restart

tmp files disappear on server restart
This commit is contained in:
Girish Ramakrishnan
2026-02-14 19:01:00 +01:00
parent c8bc6f9ffe
commit 2597402496
6 changed files with 36 additions and 22 deletions

View File

@@ -16,6 +16,7 @@ import docker from './docker.js';
import domains from './domains.js';
import eventlog from './eventlog.js';
import fs from 'node:fs';
import fileUtils from './file-utils.js';
import Location from './location.js';
import locks from './locks.js';
import logs from './logs.js';
@@ -1794,6 +1795,8 @@ async function install(data, auditSource) {
let error = manifestFormat.parse(manifest);
if (error) throw new BoxError(BoxError.BAD_FIELD, `Manifest error: ${error.message}`);
if (data.sourceArchiveFilePath) manifest.dockerImage = `local/${manifest.id}:${manifest.version}-${Date.now()}`;
error = await checkManifest(manifest);
if (error) throw error;
@@ -1868,11 +1871,6 @@ async function install(data, auditSource) {
const appId = crypto.randomUUID();
debug(`Installing app ${appId}`);
// if we have a sourceArchive rename it to appId to be picked up later in the apptask
if (data.sourceArchiveFilePath) {
if (!safe.fs.renameSync(data.sourceArchiveFilePath, `/tmp/${appId}.tar.gz`)) throw new BoxError(BoxError.FS_ERROR, 'Error moving source archive');
}
const app = {
accessRestriction,
operators,
@@ -1906,6 +1904,8 @@ async function install(data, auditSource) {
if (addError && addError.reason === BoxError.ALREADY_EXISTS) throw getDuplicateErrorDetails(addError.message, locations, portBindings);
if (addError) throw addError;
if (data.sourceArchiveFilePath) await fileUtils.renameFile(data.sourceArchiveFilePath, `${paths.SOURCE_ARCHIVES_DIR}/${appId}.tar.gz`);
const task = {
args: { restoreConfig: null, skipDnsSetup, overwriteDns },
values: { },
@@ -2312,6 +2312,8 @@ async function updateApp(app, data, auditSource) {
error = manifestFormat.parse(manifest);
if (error) throw new BoxError(BoxError.BAD_FIELD, 'Manifest error:' + error.message);
if (data.sourceArchiveFilePath) manifest.dockerImage = `local/${manifest.id}:${manifest.version}-${Date.now()}`;
error = await checkManifest(manifest);
if (error) throw error;
@@ -2364,10 +2366,7 @@ async function updateApp(app, data, auditSource) {
const hasSso = !!updateConfig.manifest.addons?.proxyAuth || !!updateConfig.manifest.addons?.ldap || !!manifest.addons?.oidc;
if (!hasSso && app.sso) values.sso = false; // turn off sso flag, if the update removes sso options
// if we have a sourceArchive rename it to appId to be picked up later in the apptask
if (data.sourceArchiveFilePath) {
if (!safe.fs.renameSync(data.sourceArchiveFilePath, `/tmp/${appId}.tar.gz`)) throw new BoxError(BoxError.FS_ERROR, 'Error moving source archive');
}
if (data.sourceArchiveFilePath) await fileUtils.renameFile(data.sourceArchiveFilePath, `${paths.SOURCE_ARCHIVES_DIR}/${appId}.tar.gz`);
const task = {
args: { updateConfig },