public async determineRuntimeStackAsync()

in src/ContainerAppHelper.ts [501:531]


    public async determineRuntimeStackAsync(appSourcePath: string): Promise<string> {
        toolHelper.writeDebug('Attempting to determine the runtime stack needed for the provided application source');
        try {
            // Use 'oryx dockerfile' command to determine the runtime stack to use and write it to a temp file
            let command = `docker run --rm -v ${appSourcePath}:/app ${ORYX_CLI_IMAGE} /bin/bash -c "oryx dockerfile /app | head -n 1 | sed 's/ARG RUNTIME=//' >> /app/oryx-runtime.txt"`
            await util.execute(command)

            // Read the temp file to get the runtime stack into a variable
            let oryxRuntimeTxtPath = path.join(appSourcePath, 'oryx-runtime.txt');

            let runtimeStack = fs.promises.readFile(oryxRuntimeTxtPath, 'utf8').then((data) => {
                let lines = data.split('\n');
                return lines[0];
            }).catch((err) => {
                toolHelper.writeError(err.message);
                throw err;
            });

            // Delete the temp file
            fs.unlink(oryxRuntimeTxtPath, (err) => {
                if (err) {
                    toolHelper.writeWarning(`Unable to delete the temporary file "${oryxRuntimeTxtPath}". Error: ${err.message}`);
                }
            });

            return runtimeStack;
        } catch (err) {
            toolHelper.writeError(err.message);
            throw err;
        }
    }