Skip to content

Setup for Self Hosted Actions Runner to deploy the API

Samanyou Garg edited this page Jul 20, 2021 · 7 revisions

Create a new non-root user

Create a user called krishna or whatever you like.

adduser krishna

Give the user sudo permissions.

usermod -aG sudo krishna

Set Up a Basic Firewall

ufw app list
ufw allow OpenSSH
ufw enable
ufw status

Install Docker and Docker Compose

Docker

Add the Docker repository to your Linux repository. Execute the following commands in a terminal window.

sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"

Install Docker Community Edition.

sudo apt-get update
sudo apt-get install docker-ce

Add your user to the docker group to setup its permissions. Make sure to restart your machine after executing this command.

sudo usermod -a -G docker <username>

Test your Docker installation. Executing the following command will automatically download the hello-world Docker image if it does not exist and run it.

docker run hello-world

Remove the hello-world image once you're done.

docker image ls
docker rmi -f hello-world

Docker Compose

Docker Compose helps you to run a network of several containers at once thanks to configuration files instead of providing all arguments in the command line interface. It makes it easier to manage your containers as command lines can become very long and unreadable due to the high number of arguments. Execute the following command in a terminal window.

sudo apt install docker-compose

Steps for setting up the runner on VM

  1. Go to the Settings tab in the GitHub project and click on the Actions menu on the sidebar.

  2. There, you'll notice the Runners tab under the Actions menu. Click on the Runners tab.

  3. On the Runners page, click the Add runner button that will take you to the Add self-hosted runner page.

  4. On the Add self-hosted runner page, choose the Operating System as Linux and Architecture type as X64, and follow the instructions mentioned on the page.

  5. After downloading the runner package, go to the configure section and configure the runner.

  6. After configuring the runner, do not run ./run.sh. This will only the runner in transient mode. To make the runner a systemd service, run the command sudo ./svc.sh install This will create a systemd service so the runner will automatically run even after the VM restarts.

  7. After installing the runner, start the runner using the command sudo ./svc.sh start. You can check the status of the runner using the command sudo ./svc.sh status.