gersilex / apcupsd-docker

apcupsd in a container; can trigger arbitrary commands on the Docker host
https://hub.docker.com/r/gersilex/apcupsd
MIT License
24 stars 12 forks source link

Linux/arm Linux/arm64 versions? #12

Open dmkw01 opened 2 years ago

dmkw01 commented 2 years ago

Is it possible to compile a Linux/arm and Linux/arm64 versions of this? I would like to run this on my Raspberry Pi Compute Module 4. Thank you very much.

gersilex commented 2 years ago

Hi @dmkw01, welcome to GitHub and congratulations on your first opened issue!

In theory, this should be very possible. I'm not actively working on this right now, as my focus has shifted big time, but if you are interested you can go and try for yourself and contribute back to this repository, if you want.

We need to use an ARM base image (the FROM: line in Dockerfile) as well as the ARM variant of APCUPSD. I'm sure there are plenty of resources online from people that acutally know it (I don't :wink: ). Let me know how it turned out!

dmkw01 commented 2 years ago

Hi Leroy!

Thank you very much for responding. I guessed as much.

I was running APCUPSD on my Pi 4 until recently when I started moving to Docker running inside OpenWRT on a SEEED Pi Compute Module 4 Router. I’ve got the hardware to do this, just not the knowledge, yet! It would be greatly appreciated if you can point me in the right direction to get me started.

Thanks again, David.

gersilex commented 2 years ago

You don't even need to use your arm64 device to build the docker image. You can do it from your main PC, for example.

https://docs.docker.com/desktop/multi-arch/

This is part of the official docs. I never tried this personally, but I do know it's possible.

nioc commented 1 year ago

Hello @dmkw01. I achieve it with this buildx script (ran on my laptop which is running under Ubuntu 22):

#!/bin/bash
NAME=apcupsd
VERSION=3.14.14
REGISTRY=mydocker.mydomain:5000
DOCKER_USER=myuser
DOCKER_PASS=pwd
ARCH=linux/amd64,linux/arm64

echo "Build $NAME $VERSION and push to $REGISTRY"

docker login $REGISTRY -u $DOCKER_USER -p $DOCKER_PASS

# Install QEMU
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes

# Go to folder containing dockerfile (this script is in a subfolder)
cd ..

# Create builder multi architecture
docker buildx create --name rpibuilder --driver docker-container --use --config rpi.toml
docker buildx inspect --bootstrap

# build and push image
docker buildx build --push --platform $ARCH -f ./Dockerfile -t "$REGISTRY/$NAME:$VERSION" -t "$REGISTRY/$NAME:latest" .

I need a rpi.toml with the following content:

[registry."mydocker.mydomain:5000"]
  http = true
  insecure = true

Maybe @gersilex you can use this build script for provide multiarch image?