Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Get a docker container with docker in it, to run on s3df, and shell into that to use for development environment (and make the files you edit permanent (overlay maybe)) Ask claudio if he had docker in docker,
  2. Design is we will have the github actions → self-hosted runner → send request to external 'build controller' container → spin up a new container which will do the image build. Basically the self-hosted runner is the one to receive request from github actions, then it sends it out to the build controller. Then the build controller can look into component database for instructions on how to build the container, then create another container to do the building. see if kubernetes cluster has its own network, so the nodes can talk to each other only, this way we can make a socket from runner to build controller and requests builds through there
  3. right now: get a basic image that just spits out it ran, then in our runner, see if we can install kubectl to ask kubectl to spin up the new basic image, and if it works then we solved our problem with running new docker containers.
  4. Try to get a dockerfile for buildroot going, most of the building will be in the dockerfile (copying over files, then running make), then the gh workflow will just call docker build and start the process, and can push the image anywhere (Local registry, docker registry, github registry)
  5. Get the build system container running on the kluster Deploying Self-Hosted GitHub Actions Runners with Docker | TestDriven.io (Altered to fit our situation) 
    1. Lets do it vanilla first (running build system container) 
      1. Create the image using base image: Package actions-runner (github.com)
        1. push the docker image to a registry so anyone can pull it
          1. From where the dockerfile is 
          2. 'docker build --tag pnispero/gh-runner-image:latest .'
          3. This step may change (make a docker account, then create a access token, which will allow you to login on your shell)
          4. 'docker push pnispero/gh-runner-image:latest'
          5. Output: pnispero/gh-runner-image - Docker Image | Docker Hub
        2. Dockerfile (Here temporarily, these are the only 2 files you need to get this to work)

          Code Block
          # base
          FROM ubuntu:22.04
          
          # set the github runner version
          ARG RUNNER_VERSION="2.316.0"
          
          # update the base packages and add a non-sudo user
          RUN apt-get update -y && apt-get upgrade -y && useradd -m docker
          
          # install python and the packages the your code depends on along with jq so we can parse JSON
          # add additional packages as necessary
          RUN DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
              curl jq build-essential libssl-dev libffi-dev python3 python3-venv python3-dev python3-pip
          
          # cd into the user directory, download and unzip the github actions runner
          RUN cd /home/docker && mkdir actions-runner && cd actions-runner \
              && curl -O -L https://github.com/actions/runner/releases/download/v${RUNNER_VERSION}/actions-runner-linux-x64-${RUNNER_VERSION}.tar.gz \
              && tar xzf ./actions-runner-linux-x64-${RUNNER_VERSION}.tar.gz
          
          # install some additional dependencies
          RUN chown -R docker ~docker && /home/docker/actions-runner/bin/installdependencies.sh
          
          # copy over the start.sh script
          COPY start.sh start.sh
          
          # make the script executable
          RUN chmod +x start.sh
          
          # since the config and run script for actions are not allowed to be run by root,
          # set the user to "docker" so all subsequent commands are run as the docker user
          USER docker
          
          # set the entrypoint to the start.sh script
          ENTRYPOINT ["./start.sh"]

          start.sh

          Code Block
          #!/bin/bash
          
          ORGANIZATION=$ORGANIZATION
          ACCESS_TOKEN=$ACCESS_TOKEN
          
          # Generate organization registration token
          REG_TOKEN=$(curl -L \
            -X POST \
            -H "Accept: application/vnd.github+json" \
            -H "Authorization: Bearer ${ACCESS_TOKEN}" \
            -H "X-GitHub-Api-Version: 2022-11-28" \
            https://api.github.com/orgs/${ORGANIZATION}/actions/runners/registration-token | jq .token --raw-output)
          
          cd /home/docker/actions-runner
          
          ./config.sh --url https://github.com/${ORGANIZATION} --token ${REG_TOKEN}
          
          cleanup() {
              echo "Removing runner..."
              ./config.sh remove --unattended --token ${REG_TOKEN}
          }
          
          trap 'cleanup; exit 130' INT
          trap 'cleanup; exit 143' TERM
          
          ./run.sh & wait $!
      2. do 'docker image ls' to ensure its there
      3. Then you must be an organization administrator, and make a personal access token with the "admin:org" and "repo" scope to create a registration token for an organization (REST API endpoints for self-hosted runners - GitHub Docs)
      4. Copy the token, and use it in the next step
      5. Run the docker image

        Code Block
        docker run \
          --env ORGANIZATION=<ORG> \
          --env ACCESS_TOKEN=<PERSONAL-TOKEN> \
          --name runner1 \
          runner-image

        Replace <ORG> with the organization name
        Replace <PERSONAL-TOKEN> with the token you created above

      6. And now your runner should be registered and running
      7. When done testing make sure to 'ctrl+c' and  'stop' and 'remove' the container
    2. Start the image using kubectl for our ad-build kubernetes cluster you created above
      1. Code Block
        # Start the image with environment variables
        kubectl run gh-runner1 --image=pnispero/gh-runner-image --env="ORGANIZATION=<ORG>" --env="ACCESS_TOKEN=<PERSONAL-TOKEN>"

        Replace <ORG> with the organization name
        Replace <PERSONAL-TOKEN> with the token you created above

    3. REMEMBER IF STOPPING THE CONTAINER, give it a grace period so it has some time to remove itself and from the organization

      Code Block
      kubectl delete --grace-period=15 pod gh-runner1
  6. Then we can use that for building buildroot. One of the workflows will be it checking out on /scratch/ in s3df, then build, and output results there.

...