Skip to content

Commit be09d19

Browse files
authored
fix(release script): support multi-stage builds when rendering Dockerfile (Unleash#42)
1 parent 94deb76 commit be09d19

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

tools/docker-utils.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const dockerfileTemplate = fs.readFileSync(
1313
'utf8',
1414
);
1515

16-
const fromLineRegExp = /FROM node:.*?\n/g;
16+
const fromStatementRegExp = /FROM node:.*?(\s|\n)/g;
1717

1818
/**
1919
* Render a Dockerfile with the correct base image.
@@ -23,8 +23,12 @@ const fromLineRegExp = /FROM node:.*?\n/g;
2323
*/
2424
function renderDockerfile({ nodeDockerVersion }) {
2525
return dockerfileTemplate.replace(
26-
fromLineRegExp,
27-
`FROM node:${nodeDockerVersion}`,
26+
fromStatementRegExp,
27+
// We need a trailing space for the first step(s) in the multi-stage build
28+
// (between "FROM node:<version>" and e.g., "as builder").
29+
// This also adds a trailing space to the end of the final
30+
// FROM statement, but it doesn't make a difference.
31+
`FROM node:${nodeDockerVersion} `
2832
);
2933
}
3034

0 commit comments

Comments
 (0)