All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.cloudsnorkel.cdk.github.runners.CodeBuildImageBuilder Maven / Gradle / Ivy

Go to download

CDK construct to create GitHub Actions self-hosted runners. Creates ephemeral runners on demand. Easy to deploy and highly customizable.

There is a newer version: 0.14.7
Show newest version
package com.cloudsnorkel.cdk.github.runners;

/**
 * (experimental) An image builder that uses CodeBuild to build Docker images pre-baked with all the GitHub Actions runner requirements.
 * 

* Builders can be used with runner providers. *

* Each builder re-runs automatically at a set interval to make sure the images contain the latest versions of everything. *

* You can create an instance of this construct to customize the image used to spin-up runners. Each provider has its own requirements for what an image should do. That's why they each provide their own Dockerfile. *

* For example, to set a specific runner version, rebuild the image every 2 weeks, and add a few packages for the Fargate provider, use: *

*

 * const builder = new CodeBuildImageBuilder(this, 'Builder', {
 *      dockerfilePath: FargateProvider.LINUX_X64_DOCKERFILE_PATH,
 *      runnerVersion: RunnerVersion.specific('2.293.0'),
 *      rebuildInterval: Duration.days(14),
 * });
 * builder.setBuildArg('EXTRA_PACKAGES', 'nginx xz-utils');
 * new FargateRunner(this, 'Fargate provider', {
 *      label: 'customized-fargate',
 *      imageBuilder: builder,
 * });
 * 
*/ @javax.annotation.Generated(value = "jsii-pacmak/1.73.0 (build 6faeda3)", date = "2023-01-17T21:04:02.918Z") @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) @software.amazon.jsii.Jsii(module = com.cloudsnorkel.cdk.github.runners.$Module.class, fqn = "@cloudsnorkel/cdk-github-runners.CodeBuildImageBuilder") public class CodeBuildImageBuilder extends software.constructs.Construct implements com.cloudsnorkel.cdk.github.runners.IImageBuilder { protected CodeBuildImageBuilder(final software.amazon.jsii.JsiiObjectRef objRef) { super(objRef); } protected CodeBuildImageBuilder(final software.amazon.jsii.JsiiObject.InitializationMode initializationMode) { super(initializationMode); } /** * @param scope This parameter is required. * @param id This parameter is required. * @param props This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public CodeBuildImageBuilder(final @org.jetbrains.annotations.NotNull software.constructs.Construct scope, final @org.jetbrains.annotations.NotNull java.lang.String id, final @org.jetbrains.annotations.NotNull com.cloudsnorkel.cdk.github.runners.CodeBuildImageBuilderProps props) { super(software.amazon.jsii.JsiiObject.InitializationMode.JSII); software.amazon.jsii.JsiiEngine.getInstance().createNewObject(this, new Object[] { java.util.Objects.requireNonNull(scope, "scope is required"), java.util.Objects.requireNonNull(id, "id is required"), java.util.Objects.requireNonNull(props, "props is required") }); } /** * (experimental) Add extra trusted certificates. This helps deal with self-signed certificates for GitHub Enterprise Server. *

* All first party Dockerfiles support this. Others may not. *

* @param path path to directory containing a file called certs.pem containing all the required certificates. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public void addExtraCertificates(final @org.jetbrains.annotations.NotNull java.lang.String path) { software.amazon.jsii.Kernel.call(this, "addExtraCertificates", software.amazon.jsii.NativeType.VOID, new Object[] { java.util.Objects.requireNonNull(path, "path is required") }); } /** * (experimental) Uploads a folder to the build server at a given folder name. *

* @param sourcePath path to source directory. This parameter is required. * @param destName name of destination folder. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public void addFiles(final @org.jetbrains.annotations.NotNull java.lang.String sourcePath, final @org.jetbrains.annotations.NotNull java.lang.String destName) { software.amazon.jsii.Kernel.call(this, "addFiles", software.amazon.jsii.NativeType.VOID, new Object[] { java.util.Objects.requireNonNull(sourcePath, "sourcePath is required"), java.util.Objects.requireNonNull(destName, "destName is required") }); } /** * (experimental) Add a policy statement to the builder to access resources required to the image build. *

* @param statement IAM policy statement. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public void addPolicyStatement(final @org.jetbrains.annotations.NotNull software.amazon.awscdk.services.iam.PolicyStatement statement) { software.amazon.jsii.Kernel.call(this, "addPolicyStatement", software.amazon.jsii.NativeType.VOID, new Object[] { java.util.Objects.requireNonNull(statement, "statement is required") }); } /** * (experimental) Adds a command that runs after `docker build` and `docker push`. *

* @param command command to add. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public void addPostBuildCommand(final @org.jetbrains.annotations.NotNull java.lang.String command) { software.amazon.jsii.Kernel.call(this, "addPostBuildCommand", software.amazon.jsii.NativeType.VOID, new Object[] { java.util.Objects.requireNonNull(command, "command is required") }); } /** * (experimental) Adds a command that runs before `docker build`. *

* @param command command to add. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public void addPreBuildCommand(final @org.jetbrains.annotations.NotNull java.lang.String command) { software.amazon.jsii.Kernel.call(this, "addPreBuildCommand", software.amazon.jsii.NativeType.VOID, new Object[] { java.util.Objects.requireNonNull(command, "command is required") }); } /** * (experimental) Called by IRunnerProvider to finalize settings and create the image builder. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) @Override public @org.jetbrains.annotations.NotNull com.cloudsnorkel.cdk.github.runners.RunnerImage bind() { return software.amazon.jsii.Kernel.call(this, "bind", software.amazon.jsii.NativeType.forClass(com.cloudsnorkel.cdk.github.runners.RunnerImage.class)); } /** * (experimental) Adds a build argument for Docker. *

* See the documentation for the Dockerfile you're using for a list of supported build arguments. *

* @param name build argument name. This parameter is required. * @param value build argument value. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public void setBuildArg(final @org.jetbrains.annotations.NotNull java.lang.String name, final @org.jetbrains.annotations.NotNull java.lang.String value) { software.amazon.jsii.Kernel.call(this, "setBuildArg", software.amazon.jsii.NativeType.VOID, new Object[] { java.util.Objects.requireNonNull(name, "name is required"), java.util.Objects.requireNonNull(value, "value is required") }); } /** */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public @org.jetbrains.annotations.NotNull com.cloudsnorkel.cdk.github.runners.CodeBuildImageBuilderProps getProps() { return software.amazon.jsii.Kernel.get(this, "props", software.amazon.jsii.NativeType.forClass(com.cloudsnorkel.cdk.github.runners.CodeBuildImageBuilderProps.class)); } /** * (experimental) A fluent builder for {@link com.cloudsnorkel.cdk.github.runners.CodeBuildImageBuilder}. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public static final class Builder implements software.amazon.jsii.Builder { /** * @return a new instance of {@link Builder}. * @param scope This parameter is required. * @param id This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public static Builder create(final software.constructs.Construct scope, final java.lang.String id) { return new Builder(scope, id); } private final software.constructs.Construct scope; private final java.lang.String id; private final com.cloudsnorkel.cdk.github.runners.CodeBuildImageBuilderProps.Builder props; private Builder(final software.constructs.Construct scope, final java.lang.String id) { this.scope = scope; this.id = id; this.props = new com.cloudsnorkel.cdk.github.runners.CodeBuildImageBuilderProps.Builder(); } /** * (experimental) Path to Dockerfile to be built. *

* It can be a path to a Dockerfile, a folder containing a Dockerfile, or a zip file containing a Dockerfile. *

* @return {@code this} * @param dockerfilePath Path to Dockerfile to be built. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public Builder dockerfilePath(final java.lang.String dockerfilePath) { this.props.dockerfilePath(dockerfilePath); return this; } /** * (experimental) Image architecture. *

* Default: Architecture.X86_64 *

* @return {@code this} * @param architecture Image architecture. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public Builder architecture(final com.cloudsnorkel.cdk.github.runners.Architecture architecture) { this.props.architecture(architecture); return this; } /** * (experimental) The type of compute to use for this build. *

* See the {@link ComputeType} enum for the possible values. *

* Default: {@link ComputeType#SMALL} *

* @return {@code this} * @param computeType The type of compute to use for this build. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public Builder computeType(final software.amazon.awscdk.services.codebuild.ComputeType computeType) { this.props.computeType(computeType); return this; } /** * (experimental) Removal policy for logs of image builds. *

* If deployment fails on the custom resource, try setting this to RemovalPolicy.RETAIN. This way the CodeBuild logs can still be viewed, and you can see why the build failed. *

* We try to not leave anything behind when removed. But sometimes a log staying behind is useful. *

* Default: RemovalPolicy.DESTROY *

* @return {@code this} * @param logRemovalPolicy Removal policy for logs of image builds. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public Builder logRemovalPolicy(final software.amazon.awscdk.RemovalPolicy logRemovalPolicy) { this.props.logRemovalPolicy(logRemovalPolicy); return this; } /** * (experimental) The number of days log events are kept in CloudWatch Logs. *

* When updating * this property, unsetting it doesn't remove the log retention policy. To * remove the retention policy, set the value to INFINITE. *

* Default: logs.RetentionDays.ONE_MONTH *

* @return {@code this} * @param logRetention The number of days log events are kept in CloudWatch Logs. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public Builder logRetention(final software.amazon.awscdk.services.logs.RetentionDays logRetention) { this.props.logRetention(logRetention); return this; } /** * (experimental) Image OS. *

* Default: OS.LINUX *

* @return {@code this} * @param os Image OS. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public Builder os(final com.cloudsnorkel.cdk.github.runners.Os os) { this.props.os(os); return this; } /** * (experimental) Schedule the image to be rebuilt every given interval. *

* Useful for keeping the image up-do-date with the latest GitHub runner version and latest OS updates. *

* Set to zero to disable. *

* Default: Duration.days(7) *

* @return {@code this} * @param rebuildInterval Schedule the image to be rebuilt every given interval. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public Builder rebuildInterval(final software.amazon.awscdk.Duration rebuildInterval) { this.props.rebuildInterval(rebuildInterval); return this; } /** * (experimental) Version of GitHub Runners to install. *

* Default: latest version available *

* @return {@code this} * @param runnerVersion Version of GitHub Runners to install. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public Builder runnerVersion(final com.cloudsnorkel.cdk.github.runners.RunnerVersion runnerVersion) { this.props.runnerVersion(runnerVersion); return this; } /** * (experimental) Security Group to assign to this instance. *

* Default: public project with no security group *

* @return {@code this} * @param securityGroup Security Group to assign to this instance. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public Builder securityGroup(final software.amazon.awscdk.services.ec2.ISecurityGroup securityGroup) { this.props.securityGroup(securityGroup); return this; } /** * (experimental) Where to place the network interfaces within the VPC. *

* Default: no subnet *

* @return {@code this} * @param subnetSelection Where to place the network interfaces within the VPC. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public Builder subnetSelection(final software.amazon.awscdk.services.ec2.SubnetSelection subnetSelection) { this.props.subnetSelection(subnetSelection); return this; } /** * (experimental) The number of minutes after which AWS CodeBuild stops the build if it's not complete. *

* For valid values, see the timeoutInMinutes field in the AWS * CodeBuild User Guide. *

* Default: Duration.hours(1) *

* @return {@code this} * @param timeout The number of minutes after which AWS CodeBuild stops the build if it's not complete. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public Builder timeout(final software.amazon.awscdk.Duration timeout) { this.props.timeout(timeout); return this; } /** * (experimental) VPC to build the image in. *

* Default: no VPC *

* @return {@code this} * @param vpc VPC to build the image in. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public Builder vpc(final software.amazon.awscdk.services.ec2.IVpc vpc) { this.props.vpc(vpc); return this; } /** * @returns a newly built instance of {@link com.cloudsnorkel.cdk.github.runners.CodeBuildImageBuilder}. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) @Override public com.cloudsnorkel.cdk.github.runners.CodeBuildImageBuilder build() { return new com.cloudsnorkel.cdk.github.runners.CodeBuildImageBuilder( this.scope, this.id, this.props.build() ); } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy