Run your CI runner on a LiveTerminal VPS
A VPS can run the CI jobs of your GitLab or GitHub projects. You install the runner program from GitLab or GitHub on the VPS; it connects out to GitLab or GitHub, picks up jobs and runs them. It needs no open ports.
Create a VPS for the runner
Section titled “Create a VPS for the runner”Use a VPS only for CI (see Security). 2 vCPUs, 4 GiB of RAM and 40 GiB of disk is a good start for Docker jobs; the disk fills with Docker images, so give it more if your jobs use large images.
lt vps create --name ci-runner --vcpus 2 --memory-gib 4 --root-disk-gib 40 --waitlt ssh-configssh ci-runner.lt.internalThe commands in the rest of this page run on the VPS.
Install Docker
Section titled “Install Docker”Both runners below run jobs in Docker containers. Install Docker Engine from Docker’s repository (Docker’s instructions for Ubuntu):
sudo apt-get updatesudo apt-get install -y ca-certificates curlsudo install -m 0755 -d /etc/apt/keyringssudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.ascsudo chmod a+r /etc/apt/keyrings/docker.ascsudo tee /etc/apt/sources.list.d/docker.sources <<EOFTypes: debURIs: https://download.docker.com/linux/ubuntuSuites: $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}")Components: stableArchitectures: $(dpkg --print-architecture)Signed-By: /etc/apt/keyrings/docker.ascEOFsudo apt-get updatesudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-pluginsudo docker run --rm hello-worldGitLab Runner
Section titled “GitLab Runner”Create the runner in GitLab
Section titled “Create the runner in GitLab”In your project, open Settings > CI/CD > Runners and choose New project runner (for a
group: the group’s Build > Runners, New group runner). Enter the tags the runner should
take jobs for, for example liveterminal, or tick Run untagged jobs. Choose Create
runner. GitLab shows a runner authentication token that starts with glrt-; you need it in
the next step. Tags are set here in GitLab, not on the VPS.
Install and register it
Section titled “Install and register it”Install GitLab Runner from GitLab’s package repository (GitLab’s instructions):
curl -L "https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.deb.sh" -o script.deb.shless script.deb.sh # read it before you run itsudo bash script.deb.shsudo apt-get install -y gitlab-runnerThe package is large (it includes helper images); the install takes about a minute. It starts the
gitlab-runner service.
Register the runner with the token from GitLab, with the Docker executor (GitLab’s instructions):
sudo gitlab-runner register \ --non-interactive \ --url "https://gitlab.com" \ --token "glrt-..." \ --executor docker \ --docker-image alpine:latest \ --description "ci-runner"sudo gitlab-runner verifyFor GitLab Self-Managed, use your instance’s URL instead of https://gitlab.com. The runner then
shows as online in GitLab. --docker-image is the image for jobs that don’t name one.
Send a job to it
Section titled “Send a job to it”A job runs on the runner when its tags match:
hello: tags: [liveterminal] image: alpine:latest script: - echo "Running on $(hostname)"Remove it
Section titled “Remove it”sudo gitlab-runner unregister --name ci-runnerThis removes the runner from the VPS. The runner stays listed in GitLab; delete it there too, under Settings > CI/CD > Runners.
GitHub Actions runner
Section titled “GitHub Actions runner”Get a registration token
Section titled “Get a registration token”In your repository, open Settings > Actions > Runners and choose New self-hosted runner (for an organization: the organization’s Settings > Actions > Runners). Pick Linux and x64. GitHub shows the commands to download the runner and a registration token; the token expires after one hour.
Install and register it
Section titled “Install and register it”Run the download commands GitHub shows, as the user dev (the runner refuses to be set up as
root). For version 2.338.2 they are:
mkdir actions-runner && cd actions-runnercurl -o actions-runner-linux-x64-2.338.2.tar.gz -L https://github.com/actions/runner/releases/download/v2.338.2/actions-runner-linux-x64-2.338.2.tar.gztar xzf ./actions-runner-linux-x64-2.338.2.tar.gzThen register it. --labels adds your own labels to the default self-hosted, linux and x64:
./config.sh --unattended \ --url https://github.com/OWNER/REPO \ --token REGISTRATION_TOKEN \ --name ci-runner \ --labels liveterminalLet the runner’s jobs use Docker, then run the runner as a systemd service, so it keeps running after you disconnect and starts again after a restart:
sudo usermod -aG docker devsudo ./svc.sh install devsudo ./svc.sh startsudo ./svc.sh statusSend a job to it
Section titled “Send a job to it”on: pushjobs: hello: runs-on: [self-hosted, liveterminal] steps: - run: echo "Running on $(hostname)"Remove it
Section titled “Remove it”In Settings > Actions > Runners, open the runner and choose Remove; GitHub shows a removal
token. On the VPS, in actions-runner:
sudo ./svc.sh stopsudo ./svc.sh uninstall./config.sh remove --token REMOVAL_TOKENGitHub removes a runner by itself when it has not connected for 14 days.
Keep them updated
Section titled “Keep them updated”- GitLab Runner updates with the system packages:
sudo apt-get update && sudo apt-get install -y gitlab-runner. Keep it close to your GitLab version. - GitHub Actions runner updates itself when a new version comes out, unless you registered it
with
--disableupdate. A runner that is too old stops getting jobs. - Docker and Ubuntu: run
sudo apt-get update && sudo apt-get upgrade -yfrom time to time.
Security
Section titled “Security”A CI job runs whatever code is in the commit it builds, and on this VPS it can reach everything the runner can.
- Use a VPS only for CI. Don’t keep other work, keys or agent logins on it. A job in a Docker container can get root on the VPS through Docker.
- Don’t run jobs from people you don’t trust. Don’t attach the runner to a public project or repository, and don’t let it run jobs for merge requests or pull requests from forks: anyone who can open one can run code on your VPS and read what it can read. GitHub says self-hosted runners should almost never be used for public repositories.
- Secrets. CI variables and secrets reach the jobs that run on the VPS, and files the jobs
write stay on its disk. Use protected or environment-scoped secrets, and delete the VPS (with
lt vps delete --now) when you stop using it. - Tokens. The
glrt-token and the GitHub registration token let a machine join as your runner. Don’t commit them; GitLab Runner keeps its token in/etc/gitlab-runner/config.toml.
What it costs
Section titled “What it costs”A runner VPS is billed like any other VPS: its vCPUs and RAM for the time it runs, whether jobs
run or not, its disk for as long as it exists, and the traffic it sends (for example artifacts and
caches it uploads). Nothing extra is charged for CI. A stopped VPS (lt vps stop ci-runner) runs
no jobs and is billed only for its disk; lt vps start ci-runner brings the runner back.