Support and prefer Dockerfile.cloudron in local builds

This commit is contained in:
Johannes Zellner
2026-03-02 12:06:27 +01:00
parent 4cc1926899
commit 2a6d385cea

View File

@@ -137,8 +137,21 @@ async function buildImage(dockerImage, sourceArchiveFilePath) {
debug(`buildImage: building ${dockerImage} from ${sourceArchiveFilePath}`);
const buildOptions = { t: dockerImage };
const [listError, listOut] = await safe(shell.spawn('tar', ['-tzf', sourceArchiveFilePath], { encoding: 'utf8' }));
if (!listError && listOut) {
const dockerfileCloudronPath = listOut.split('\n').map(line => line.trim()).find(line => {
const path = line.replace(/\/$/, '');
return path.endsWith('Dockerfile.cloudron');
});
if (dockerfileCloudronPath) {
buildOptions.dockerfile = dockerfileCloudronPath.replace(/\/$/, '');
debug(`buildImage: using ${buildOptions.dockerfile}`);
}
}
const tarStream = fs.createReadStream(sourceArchiveFilePath);
const [error, stream] = await safe(gConnection.buildImage(tarStream, { t: dockerImage }));
const [error, stream] = await safe(gConnection.buildImage(tarStream, buildOptions));
if (error) throw new BoxError(BoxError.DOCKER_ERROR, `Unable to build image from ${sourceArchiveFilePath}: ${error.message}`);
return new Promise((resolve, reject) => {