Skip to content
This repository has been archived by the owner on Dec 12, 2022. It is now read-only.

Commit

Permalink
fix(release script): support multi-stage builds when rendering Docker…
Browse files Browse the repository at this point in the history
…file (#42)
  • Loading branch information
theneva authored Mar 12, 2021
1 parent 94deb76 commit be09d19
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions tools/docker-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const dockerfileTemplate = fs.readFileSync(
'utf8',
);

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

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

Expand Down

0 comments on commit be09d19

Please sign in to comment.