Trouble building Tailscale for Pi 3B

I’ve got BalenaOS and Anthias installed on a Pi 3B. This is built using the 32 bit OS because when I attempted to build using 64 bit that failed. Everything runs great. I’d like to add the device to our Tailscale network so I can remotely update the Anthias configuration. The build however is failing. Any assistance in resolving this would be great. If the answer is to use a different build, that’d be OK too.

Ref: GitHub - hslatman/tailscale-balena-rpi: Raspberry Pi 3 powered by Balena serving Tailscale mesh VPN node

$ balena build --fleet myfleet
[Build] Building services…
[Build] tailscale Preparing…
[Info] Building for armv7hf/raspberrypi3
[Build] tailscale Step 1/21 : ARG BALENA_MACHINE_NAME_ARG=raspberrypi3
[Build] tailscale Step 2/21 : FROM balenalib/$BALENA_MACHINE_NAME_ARG-debian-golang:build as builder
[Build] tailscale —> cfbbb661ff22
[Build] tailscale Step 3/21 : ENV BALENA_MACHINE_NAME raspberrypi3
[Build] tailscale —> [Warning] The requested image’s platform (linux/arm/v7) does not match the detected host platform (linux/amd64/v4) and no specific platform was requested
[Build] tailscale —> Running in 9b5993537f3e
[Build] tailscale —> Removed intermediate container 9b5993537f3e
[Build] tailscale —> 943b6c967c1d
[Build] tailscale Step 4/21 : ENV BALENA_OS_VERSION 6.5.50+rev2.prod
[Build] tailscale —> [Warning] The requested image’s platform (linux/arm/v7) does not match the detected host platform (linux/amd64/v4) and no specific platform was requested
[Build] tailscale —> Running in 107760ea97b8
[Build] tailscale —> Removed intermediate container 107760ea97b8
[Build] tailscale —> 62406f24c32e
[Build] tailscale Step 5/21 : RUN install_packages curl build-essential libelf-dev libssl-dev pkg-config git flex bison bc python kmod
[Build] tailscale —> [Warning] The requested image’s platform (linux/arm/v7) does not match the detected host platform (linux/amd64/v4) and no specific platform was requested
[Build] tailscale —> Running in 788e6c6a7246
[Build] tailscale exec /bin/sh: exec format error
[Build] Built 1 service in 0:01
[Error] Build failed.
The command ‘/bin/sh -c install_packages curl build-essential libelf-dev libssl-dev pkg-config git flex bison bc python kmod’ returned a non-zero code: 255

Hello, I tried building that project and did not get that error. The only env line I changed was ENV BALENA_OS_VERSION 6.5.50+rev2 without the .prod

You’ll also need to change the line:

RUN curl -L -o headers.tar.gz $(echo "https://files.balena-cloud.com/images/$BALENA_MACHINE_NAME/$BALENA_OS_VERSION/kernel_modules_headers.tar.gz" | sed -e 's/+/%2B/') && \  
    tar -xf headers.tar.gz

to:

RUN curl -L -o headers.tar.gz $(echo "https://files.balena-cloud.com/images/$BALENA_MACHINE_NAME/$BALENA_OS_VERSION/kernel-source.tar.gz" | sed -e 's/+/%2B/') && \  
    tar -xf headers.tar.gz

Since this example is a bit older and also uses the deprecated balenalib base image, have you considered using Tailscale’s official Docker image?

Also note that you could use balena’s public URL feature to access the Anthias config page instead of Tailscale: Actions and Settings | balena

(The Public Device URL feature is a tool for remote configuration, debugging, and other intermittent or periodic use cases.)

Using the Tailscale official image would be OK, I’m not sure how to use it. On my other devices, I ssh into them and run docker commands to retrieve the images, build them, and get them running. With Balena, I don’t know how to setup a build environment from scratch. All I’ve done to date is copy a git installation that has everything setup and then use balena build to create the installation.

It looks like I’m getting closer. I was able to build tailscale and install it.

My Dockerfile.template:

FROM tailscale/tailscale:latest

# You can add any specific dependencies or configurations needed for your Balena setup here.
# For example, if you need specific tools for debugging or other services.
# RUN apt-get update && apt-get install -y --no-install-recommends some-tool && rm -rf /var/lib/apt/lists/*

# Set the entrypoint to run tailscaled
ENTRYPOINT ["tailscaled"]

My docker-compose.yml

version: "2.1"

volumes:
  tailscale-state: {}

services:
  tailscale:
    # privileged may be optional, but requires manual step in that case
    # https://github.com/tailscale/tailscale/issues/504
    privileged: true
    environment:
      - TS_AUTHKEY="myauthkey"
    build:
      context: ./tailscale-official
      dockerfile: Dockerfile.template
    cap_add:
      - NET_ADMIN
      - NET_RAW
    network_mode: host
    volumes:
      - tailscale-state:/tailscale
    devices:
      - /dev/net/tun:/dev/net/tun
    labels:
      io.balena.features.kernel-modules: '1'
      io.balena.features.sysfs: '1'

According to the Balena dashboard, tailscale is running. My current problem is that Tailscale doesn’t seem to have tried to authenticate as I can’t see it in my Tailscale machine list waiting for authentication.

And it works! I used the Balena dashboard to connect a Tailscale terminal session. Once connected, I ran “tailscale up” and completed the authentication steps. I can ping the device. Looks like I need to make port 80 on the PI available via the docker container. Off to figure that out.