Piotr Synowiec
Piotr Synowiec
1 min read

Categories

Tags

  • create storage pool for runners
    $ lxc storage create docker btrfs - once
    
  • create lxc container for your runner, where X is just the next number or whatever you want to use
    $ lxc launch images:ubuntu/22.04 gh-runner-X 
    
  • create storage volume for the runner
    $ lxc storage volume create docker gh-runner-X
    
  • attach volume to the container
    $ lxc config device add gh-runner-X docker disk pool=docker source=gh-runner-X path=/var/lib/docker
    
  • extra config to run docker inside container
    $ lxc config set gh-runner-X security.nesting=true security.syscalls.intercept.mknod=true security.syscalls.intercept.setxattr=true
    
  • restart container
    $ lxc restart gh-runner-X
    
  • enter container
    $ lxc exec gh-runner-X bash
    
  • update
    $ sudo apt-get update
    $ sudo apt-get install ca-certificates curl gnupg lsb -y
    
  • add Docker GPG key
    $ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
    
  • add docker repository
    $ echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null 
    
  • install docker
    $ sudo apt-get update
    $ sudo apt-get install docker-ce docker-ce-cli containerd.io -y
    
  • test docker, this should enter new docker container, type exit to exit :)
    $ docker run -it ubuntu bash
    
  • go through Create self-hosted runner on GitHub
  • on config.sh run edit config.sh and comment first line with exit 1
  • create systemd service file by running
    $ ./svc.sh install
    
  • edit created file and add vars to [Service] section
    Environment="COMPOSER_HOME=/root"
    Environment="HOME=/root"
    Environment="COMPOSER_ALLOW_SUPERUSER=1"
    
  • reboot container
    $ reboot
    
  • enter container and verify if runner is working
    $ lxc exec gh-runner-X bash
    $ systemctl status <your service name file> 
    

Resources