Using Build Spec to install yarn
#247
-
I'm a little confused as to how to properly install
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Understanding now that is only for use with the actual runner and I need to install |
Beta Was this translation helpful? Give feedback.
-
You would have to configure your runner image builder to build images with your additional requirements. If you are building AMI or a container image for Windows, it's pretty straightforward (and copied from README.md). const myWindowsBuilder = new ContainerImageBuilder(this, 'Windows image builder', {
architecture: Architecture.X86_64,
os: Os.WINDOWS,
runnerVersion: RunnerVersion.specific('2.291.0'),
rebuildInterval: Duration.days(14),
});
myWindowsBuilder.addComponent(new ImageBuilderComponent(this, 'Ninja Component',
{
displayName: 'Ninja',
description: 'Download and install Ninja build system',
platform: 'Windows',
commands: [
'Invoke-WebRequest -UseBasicParsing -Uri "https://github.com/ninja-build/ninja/releases/download/v1.11.1/ninja-win.zip" -OutFile ninja.zip',
'Expand-Archive ninja.zip -DestinationPath C:\\actions',
'del ninja.zip',
],
}
));
const myProvider = new FargateRunnerProvider(this, 'fargate runner', {
label: 'customized-windows-fargate',
vpc: vpc,
securityGroup: runnerSg,
imageBuidler: myWindowsBuilder,
});
// create the runner infrastructure
new GitHubRunners(this, 'runners', {
providers: [myProvider],
}); Linux would be almost identical (if you're building an AMI): const myBuilder = new AmiBuilder(this, 'AMI builder', {
architecture: Architecture.X86_64,
os: Os.LINUX,
});
myBuilder.addComponent(new ImageBuilderComponent(this, 'Yarn',
{
displayName: 'Yarn',
description: 'Download and install Yarn',
platform: 'Linux',
commands: [
'npm install -g yarn',
],
}
));
const myProvider = new Ec2RunnerProvider(this, 'ec2 runner with yarn', {
labels: ['ec2-with-yarn'],
imageBuidler: myBuilder,
});
// create the runner infrastructure
new GitHubRunners(this, 'runners', {
providers: [myProvider],
}); If you want to build a runner image for Linux with a provider that needs a Docker image, it's a bit more complicated. First figure out which Dockerfile you want to modify. Each provider has two constants pointing to the paths of Dockerfiles it uses by default. cdk-github-runners/src/providers/codebuild.ts Lines 123 to 147 in a62cecf All of the Dockerfiles are under the same folder. For example, if you're trying to create a CodeBuild runner provider on x64, it's here. Most Dockerfiles have some arguments you can override. Those are also documented in the constants pointing to them from the provider as you can see above. If you just want to install an extra package, there is an argument to override for that. const builder = new CodeBuildImageBuilder(stack, 'codebuild image builder', {
dockerfilePath: CodeBuildRunnerProvider.LINUX_X64_DOCKERFILE_PATH,
architecture: Architecture.X86_64,
});
builder.setBuildArg('EXTRA_PACKAGES', 'yarnpkg');
new GitHubRunners(this, 'runners', {
providers: [
new CodeBuildRunnerProvider(this, 'provider', {
imageBuilder: builder,
});
],
}); If you want to add arbitrary commands, you will have to completely override the Dockerfile. This can be useful in your case if the version of Yarn that comes with Ubuntu is not new enough. In this case, you would make a copy of the relevant Dockerfile and modify it to your liking. You would then point the builder to your Dockerfile directory instead of In the future I plan to make a generic component that can be added to both Docker image builders and AMI builders. This should make this process easier. There will be no more need to hunt down and copy any Dockerfile. |
Beta Was this translation helpful? Give feedback.
-
With version 0.9.0 you can now use the following on all runner providers:
|
Beta Was this translation helpful? Give feedback.
You would have to configure your runner image builder to build images with your additional requirements. If you are building AMI or a container image for Windows, it's pretty straightforward (and copied from README.md).