-
Notifications
You must be signed in to change notification settings - Fork 156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(base_image): add custom base_image argument #103
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd revert the formatting changes and maybe explain in more detail what exactly base_image
does.
But otherwise this is a really good addition!
Thank you for your like! I have reverted the formatting. Currently, we can't use a custom Dockerfile but the Dockerfiles in this repo. But when you have a look at these Dockerfiles, the most meaningful thing is just the FROM line, which defines the base image of the build environment. The arch-related things are handled by the buildkit and qemu automatically, but not here. The core part of the PR is: const arch = core.getInput('arch', {
required: true
});
const distro = core.getInput('distro', {
required: true
});
const base_image = core.getInput('base_image', {
required: false
});
// If bad arch/distro passed, fail fast before installing all the qemu stuff
const dockerFile = path.join(
__dirname, '..', 'Dockerfiles', `Dockerfile.${arch}.${distro}`);
// If a custom base image is given, then dynamically create its Dockerfile.
if (base_image) {
let lines = [];
lines.push(`FROM ${base_image}`);
lines.push("COPY ./run-on-arch-install.sh /root/run-on-arch-install.sh");
lines.push("RUN chmod +x /root/run-on-arch-install.sh && /root/run-on-arch-install.sh");
console.log(`Writing custom Dockerfile to: ${dockerFile} ...`);
fs.writeFileSync(dockerFile, lines.join("\n"));
}
if (!fs.existsSync(dockerFile)) {
throw new Error(`run-on-arch: ${dockerFile} does not exist.`);
} The basic idea here is to add a base_image input parameter and only if it is set, the script would generate a Dockerfile based on the base image you given with the name from arch and distro. This will give the end user a chance to replace an existing predefined Dockerfile or add a new combination by themself. |
Hi @LonghronShen ! |
Oh, sorry for misunderstanding. Let me add more description there. |
Hi, yes, I would put an example of a valid base_image value in the readme (maybe with a link to docket hub to make it even more clear) and that could be enough. |
I have added some documentation there. By the way, with this PR merged, some issues related to native x86_64 build within the same matrix should also be addressed, because they can freely use native x86_64 images now, or mips64el, or others that qemu and docker can handle. |
Yeah, the idea behind the Dockerfiles was to provide basic and tested defaults that you could just use without searching for one on docker hub, but it has now become a nightmare to manages. The default will stay but in a simpler default_images file easier to maintain for me. |
As for native x86_64 support, there are two options:
I prefer the option 2. |
Included in 2.5.0, arch and distro should now be |
Address the issue #25
It would be more flexible to use a custom base image.