Support and prefer Dockerfile.cloudron in local builds
This commit is contained in:
@@ -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) => {
|
||||
|
||||
Reference in New Issue
Block a user