Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ After the end of Debian LTS support, the corresponding Debian release is dropped
### Image Creation Automation

- Every 15 minutes, the [workflow](https://github.com/nodejs/docker-node/blob/main/.github/workflows/automatic-updates.yml) within the [nodejs/docker-node](https://github.com/nodejs/docker-node) repo [checks](https://github.com/nodejs/docker-node/blob/main/build-automation.mjs) for new versions of Node.js [published to the website's `index.json` file](https://nodejs.org/download/release/index.json).
- If found, it also checks for an [unofficial musl/Alpine build](https://unofficial-builds.nodejs.org/download/release/index.json).
- If found, the [update script](https://github.com/nodejs/docker-node/blob/main/update.sh) runs
- The workflow opens a pull request either automatically via [nodejs-github-bot](https://github.com/nodejs-github-bot) or in some cases manually, such as when there is a new major release.
- Another [workflow](https://github.com/nodejs/docker-node/blob/main/.github/workflows/official-pr.yml) detects the merger of these pull requests and opens a pull request to [docker-library/official-images](https://github.com/docker-library/official-images).
Expand Down
6 changes: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -256,12 +256,6 @@ message "no matching manifest". In this case, check back later.
(See [Docker Library FAQs](https://github.com/docker-library/faq#an-images-source-changed-in-git-now-what)
for a detailed description of the complex build process.)

For Node.js security releases, Debian-based `node` images may be published in advance
of Alpine-based images. To build an Alpine-based `node` image requires
a `musl` build. This may not initially be ready at Node.js release time.
When processing non-security Node.js releases, the build process will wait for
the `musl` build before proceeding with Debian- and Alpine-based images.

## License

[License information](https://github.com/nodejs/node/blob/main/LICENSE) for
Expand Down
49 changes: 5 additions & 44 deletions build-automation.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -78,59 +78,20 @@ const checkIfThereAreNewVersions = async (github) => {
}
};

// a function that queries the Node.js unofficial release website for new musl versions and security releases,
// and returns relevant information
const checkForMuslVersionsAndSecurityReleases = async (github, versions) => {
try {
const { data: unofficialBuildsIndexText } = await github.request(
'https://unofficial-builds.nodejs.org/download/release/index.json',
);

for (let version of Object.keys(versions)) {
const buildVersion = unofficialBuildsIndexText.find(
(indexVersion) =>
indexVersion.version === `v${versions[version].fullVersion}`,
);

versions[version].muslBuildExists =
buildVersion?.files.includes('linux-x64-musl') ?? false;
versions[version].isSecurityRelease = buildVersion?.security ?? false;
}
return versions;
} catch (error) {
console.error(error);
process.exit(1);
}
};

export default async function (github) {
// if there are no new versions, exit gracefully
// if there are new versions,
// check for musl builds
// then run update.sh
// if there are new versions, run update.sh
const { shouldUpdate, versions } = await checkIfThereAreNewVersions(github);

if (!shouldUpdate) {
console.log('No new versions found. No update required.');
process.exit(0);
} else {
const newVersions = await checkForMuslVersionsAndSecurityReleases(
github,
versions,
);
let updatedVersions = [];
for (const [version, newVersion] of Object.entries(newVersions)) {
if (newVersion.muslBuildExists) {
const { stdout } = await exec(
`./update.sh ${newVersion.isSecurityRelease ? '-s ' : ''}${version}`,
);
console.log(stdout);
updatedVersions.push(newVersion.fullVersion);
} else {
console.log(
`Skipping version ${newVersion.fullVersion} - no musl build available yet.`,
);
}
for (const [version, newVersion] of Object.entries(versions)) {
const { stdout } = await exec(`./update.sh ${version}`);
console.log(stdout);
updatedVersions.push(newVersion.fullVersion);
}

if (updatedVersions.length === 0) {
Expand Down
10 changes: 2 additions & 8 deletions update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,22 @@ function usage() {
Update the node docker images.

Usage:
$0 [-s] [MAJOR_VERSION(S)] [VARIANT(S)]
$0 [MAJOR_VERSION(S)] [VARIANT(S)]

Examples:
- update.sh # Update all images
- update.sh -s # Update all images, skip updating Alpine if the musl build is unavailable
- update.sh 22,24 # Update all variants of version 22 and 24
- update.sh -s 24 # Update all variants of version 24, except skip updating Alpine if the musl build is unavailable
- update.sh 24 alpine3.23,alpine3.24 # Update only alpine3.23 & alpine3.24 variants for version 24
- update.sh . trixie,trixie-slim # Update only trixie & trixie-slim Debian variants for all versions

OPTIONS:
-s Security update; allows Debian updates even if musl build for Alpine is unavailable
-h Show this message

EOF
}

while getopts "sh" opt; do
while getopts "h" opt; do
case "${opt}" in
s)
shift
;;
h)
usage
exit
Expand Down
Loading