Skip to content
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

Use pre-installed GitHub runner on the AMI #38

Closed
machulav opened this issue Apr 21, 2021 · 4 comments · Fixed by #56
Closed

Use pre-installed GitHub runner on the AMI #38

machulav opened this issue Apr 21, 2021 · 4 comments · Fixed by #56
Labels
documentation Improvements or additions to documentation enhancement New feature or request

Comments

@machulav
Copy link
Owner

machulav commented Apr 21, 2021

From @jdraymon in #16:

Would it make sense to have a version fixed in our AMI instead? or maybe a download URI with a default? My organization is a bit wary about downloading things off of the web for every build. Maybe a separate enhancement?

Let's keep it separate and collect feedback from the others.

@keithalpichi
Copy link

I think this is a great idea. The way I'd like it to work is I prepare the AMI with the Github Runner and any other dependencies. Then I run this Github Action and expect it to just start it for me.

Of course, this Github Action will need to know where the config and run scripts are located so they can be invoked. This could be another input.

@jpalomaki
Copy link
Collaborator

jpalomaki commented Jul 22, 2021

FWIW, here's an example AMI build (NOTE: for Ubuntu arm64) that pre-bakes the actions-runner software (and dependencies) in the image, so that we don't need to download/install those at runner boot-time (should somewhat improve reliability and startup time).

Here's how I currently use this AMI (:warning: experimental), which I think is pretty close to what @keithalpichi describes above (plus it uses a non-root user for the runner).

See also: philips-labs/terraform-aws-github-runner scripts

In ec2-github-runner action, the instance user-data script could perhaps be varied based on such action inputs, to allow users to choose between the current behavior of installing stuff on the fly (for backwards-compatibility, and to make it possible to use vanilla-ish AMIs) and that of using a pre-installed runner, depending on what type of AMI is being used?

@jpalomaki
Copy link
Collaborator

@machulav @keithalpichi Here's a quick stab at it: #56. Let me know what you think.

@machulav
Copy link
Owner Author

Using the changes from the PR above I'm able now to use pre-baked AMI with installed actions-runner software.

I've configured it using the following steps:

  1. Create a new EC2 instance based on Amazon Linux 2.
  2. Connect to the instance using SSH and install the following tools.
 sudo yum update -y && \
 sudo yum install docker -y && \
 sudo yum install git -y && \
 sudo systemctl enable docker
  1. Create a new actions-runner folder in the /root folder using the root user. So the folder with the runner will be /root/actions-runner. For some reason, the runner is not able to run from the /actions-runner folder in the root directory.
mkdir actions-runner && cd actions-runner
  1. Determine the architecture and set it into the ENV variable.
case $(uname -m) in aarch64) ARCH="arm64" ;; amd64|x86_64) ARCH="x64" ;; esac && export RUNNER_ARCH=${ARCH}
  1. Download the latest version of the runner.
curl -O -L https://github.com/actions/runner/releases/download/v2.278.0/actions-runner-linux-${RUNNER_ARCH}-2.278.0.tar.gz
  1. Extract the runner.
tar xzf ./actions-runner-linux-${RUNNER_ARCH}-2.278.0.tar.gz
  1. Create a new EC2 image (AMI) from the instance.
  2. Use the AMI for creating the runner.
  3. Follow the rest of the steps from the How to start
  4. Use the runner-home-dir: /root/actions-runner in the start EC2 runner configuration

@machulav machulav added documentation Improvements or additions to documentation enhancement New feature or request labels Aug 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants