Skip to content
This repository has been archived by the owner on Feb 10, 2024. It is now read-only.

Commit

Permalink
docker
Browse files Browse the repository at this point in the history
  • Loading branch information
koendv committed Jun 23, 2022
1 parent 7604dca commit 9e4ac7e
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 37 deletions.
67 changes: 30 additions & 37 deletions README-DEVELOPER.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@ Compilation using github actions requires
On the raspberry pi runner:

- Install Raspberry Pi OS 64-bit.
- install dependencies: node, yarn, and libraries.

```
sudo apt-get install libxkbfile-dev libsecret-1-dev
```
- install [docker](https://docs.docker.com/engine/install/debian/#install-using-the-convenience-script).

## patch arduino-ide

Expand All @@ -42,68 +38,65 @@ git push
In .github/workflows/build.yml, this adds a new os "self-hosted", next to Windows, Ubuntu and MacOS.

## configure self-hosted runner
On github

- configure a new self-hosted runner.
On github.com, go to your fork of the arduino-ide.
- In _Settings -> Moderation options -> Code review limits_, enable "Limit to users explicitly granted read or higher access"
- In _Settings -> Actions -> Runners -> New Self-hosted Runner_, choose:
- Runner image: Linux
- Architecture: ARM64
- Follow instructions to create a self-hosted runner, from "Create a folder" to "Last step, run it!".
- In _Settings -> General -> Code and Automation -> Actions -> Runners_, click on _New Self-Hosted Runner_.

## install node and yarn
## set up docker

- Install node and yarn. node needs to be version 14.
For repeatability and convenience, the self-hosted runner runs in a docker image. On the raspberry, type:

```
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
. ~/.config/nvm/nvm.sh
. ~/.config/nvm/bash_completion
nvm install 14.0.0
npm install --global yarn
git clone https://github.com/myoung34/docker-github-actions-runner
cd docker-github-actions-runner
patch -p1 < ../arduino-ide-raspberrypi/docker-github-actions-runner.patch
```

- make sure python is python 3, not python 2.

Copy the shell script to run docker:
```
python -v
cp ../arduino-ide-raspberrypi/docker-github-actions-runner.sh .
```
Edit `docker-github-actions-runner.sh`.

## build ide

Verify node and yarn are available before starting the runner.
- REPO_URL should point to your fork or the arduino-ide
- ACCESS_TOKEN should be your github access token (=password).

Start the self-hosted runner:
```
node --version
yarn --version
./run.sh
./docker-github-actions-runner.sh
```


This should output _Listening for Jobs_.

## start the build

On github.com, go to your fork of the arduino-ide.

- In "Actions", under "Workflows" choose "Arduino IDE", enable workflow and click "Run workflow"
- In "Actions", under "Workflows" choose "Arduino IDE", enable workflow.
- Click "Run workflow"
- On the runner, output should be ``Running job: build (self-hosted)``. You can follow what happens in the build through the github web interface.

Build time is 35-45 minutes on a raspberry pi 4b, 8gb ram.
Build time is less than one hour on a raspberry pi 4b, 8gb ram.
```
$ ./run.sh
√ Connected to GitHub
Current runner version: '2.290.1'
2022-04-29 06:52:32Z: Listening for Jobs
2022-04-29 06:56:32Z: Running job: build (self-hosted)
2022-04-29 07:37:11Z: Job build (self-hosted) completed with result: Succeeded
Current runner version: '2.294.0'
2022-06-23 13:07:35Z: Listening for Jobs
2022-06-23 13:09:38Z: Running job: build (self-hosted)
2022-06-23 13:54:14Z: Job build (self-hosted) completed with result: Succeeded
```

## download binaries

- After the run, arm64 binaries for raspberry pi are in "Artifacts."
- After the run, arm64 binaries for raspberry pi are on github, in "Artifacts."
- On github.com, go to your fork of the arduino-ide. Under "All workflows - Showing runs from all workflows" click on "Arduino IDE". The binaries are under "Artifacts - Produced during runtime
":
``Linux_ARM64_app_image`` and
``Linux_ARM64_zip``. Click to download.

- When the build is completed, stop the ``run.sh`` command. Someone might fork _your_ repository, do a pull request and [run code on your raspberry](https://docs.github.com/en/actions/hosting-your-own-runners/about-self-hosted-runners#self-hosted-runner-security). Still, with "Limit to users explicitly granted read or higher access" enabled, you would have to explicitly grant the user access first.
- When the binaries have been downloaded, delete your arduino-ide fork. It is no longer needed.
- When the build is completed, stop the runner and delete your arduino-ide fork. It is no longer needed.

not truncated.
40 changes: 40 additions & 0 deletions docker-github-actions-runner.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
diff --git a/Dockerfile b/Dockerfile
index 4d87988..9b403a0 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -6,7 +6,7 @@ ENV AGENT_TOOLSDIRECTORY=/opt/hostedtoolcache
RUN mkdir -p /opt/hostedtoolcache

ARG GH_RUNNER_VERSION="2.294.0"
-ARG TARGETPLATFORM
+ARG TARGETPLATFORM="linux/arm64"

SHELL ["/bin/bash", "-o", "pipefail", "-c"]

@@ -17,6 +17,12 @@ RUN chmod +x /actions-runner/install_actions.sh \
&& /actions-runner/install_actions.sh ${GH_RUNNER_VERSION} ${TARGETPLATFORM} \
&& rm /actions-runner/install_actions.sh

+# install arduino ide build dependencies
+RUN apt-get install -y libxkbfile-dev libsecret-1-dev
+
+# install nvm
+RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
+
COPY token.sh entrypoint.sh /
RUN chmod +x /token.sh /entrypoint.sh

diff --git a/entrypoint.sh b/entrypoint.sh
index 3b29d58..5df4be8 100644
--- a/entrypoint.sh
+++ b/entrypoint.sh
@@ -124,5 +124,9 @@ if [[ ${_DISABLE_AUTOMATIC_DEREGISTRATION} == "false" ]]; then
trap deregister_runner SIGINT SIGQUIT SIGTERM INT TERM QUIT
fi

+. $HOME/.nvm/nvm.sh
+nvm install 14.0.0
+npm install --global yarn
+
# Container's command (CMD) execution
"$@"
11 changes: 11 additions & 0 deletions docker-github-actions-runner.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh

# before use, modify:
# DOCKER_DIR is the directory of 'git clone https://github.com/myoung34/docker-github-actions-runner'
# ACCESS_TOKEN is your github access token
# REPO_URL is the url of your fork of the arduino ide

DOCKER_DIR=/home/koen/src/docker-github-actions-runner

docker build ${DOCKER_DIR} --tag ubuntu-bionic
docker run --env 'ACCESS_TOKEN=ghp_your_github_token' --env RUNNER_SCOPE=repo --env 'REPO_URL=https://github.com/your_github/arduino-ide' --env RUNNER_NAME=arduino-ide-runner ubuntu-bionic

0 comments on commit 9e4ac7e

Please sign in to comment.