Introduction
Il est nécessaire d’avoir installé au préalable Docker sur votre Archlinux.
Pour construire une image Docker compatible ARM64 pour le Raspberry PI vous aurez besoin de 3 fichiers:
- build.sh
- platform.sh
- Dockerfile
- run.sh (à placer dans un sous-répertoire work)
Fichiers requis
platform.sh
[Fichier]
#!/bin/bash
# Used in Docker build to set platform dependent variables
case $TARGETARCH in
"amd64")
echo "x86_64-unknown-linux-gnu" > /.platform
echo "" > /.compiler
;;
"arm64")
echo "aarch64-unknown-linux-gnu" > /.platform
echo "gcc-aarch64-linux-gnu" > /.compiler
;;
"arm")
echo "armv7-unknown-linux-gnueabihf" > /.platform
echo "gcc-arm-linux-gnueabihf" > /.compiler
;;
esac
build.sh
[Fichier]
#!/bin/bash
# ----------------------------------
# https://github.com/michaelmiklis/docker-rpi-monitor
# https://www.balena.io/docs/reference/base-images/base-images-ref/
# ----------------------------------
clear
cd \"\$\(dirname \"\$0\")\" \|| exit 1
IMAGE_BASE=zogg/rpi-monitor
IMAGE_NAME_LATEST=${IMAGE_BASE}:latest
export DOCKER_CLI_EXPERIMENTAL=enabled
docker run --privileged --rm tonistiigi/binfmt --install all
docker buildx build --pull \
--platform=linux/arm64 \
--output=type=docker \
--build-arg TZ=Europe/Paris \
--build-arg CONCURRENCY=$(nproc) \
-t "${IMAGE_NAME_LATEST}" \
. 2>&1 | tee build.log
exit 0
run.sh
[Fichier]
#!/bin/bash
# Load shared libraries from /opt/vc/lib
echo /opt/vc/lib > /etc/ld.so.conf.d/00-vmcs.conf
ldconfig
# Link /opt/vc/bin binaries to /usr/bin
ln -s /opt/vc/bin/raspividyuv /usr/bin/raspividyuv
ln -s /opt/vc/bin/dtmerge /usr/bin/dtmerge
ln -s /opt/vc/bin/raspistill /usr/bin/raspistill
ln -s /opt/vc/bin/vcgencmd /usr/bin/vcgencmd
ln -s /opt/vc/bin/vcdbg /usr/bin/vcdbg
ln -s /opt/vc/bin/dtoverlay-pre /usr/bin/dtoverlay-pre
ln -s /opt/vc/bin/raspiyuv /usr/bin/raspiyuv
ln -s /opt/vc/bin/vchiq_test /usr/bin/vchiq_test
ln -s /opt/vc/bin/tvservice /usr/bin/tvservice
ln -s /opt/vc/bin/edidparser /usr/bin/edidparser
ln -s /opt/vc/bin/raspivid /usr/bin/raspivid
ln -s /opt/vc/bin/dtoverlay-post /usr/bin/dtoverlay-post
ln -s /opt/vc/bin/dtoverlay /usr/bin/dtoverlay
ln -s /opt/vc/bin/dtparam /usr/bin/dtparam
# Insert Docker Host hostname into raspbian.conf
DOCKERHOST=$(cat /dockerhost/etc/hostname)
sed -i "s/'+data.hostname+'/$DOCKERHOST/g" /etc/rpimonitor/template/raspbian.conf
# Update RPI Monitor Package Status
/etc/init.d/rpimonitor install_auto_package_status_update
/usr/share/rpimonitor/scripts/updatePackagesStatus.pl
# Start RPI Monitor
/usr/bin/rpimonitord -v
Dockerfile
[Fichier]
FROM --platform=$BUILDPLATFORM balenalib/raspberrypi4-64:latest
ARG TARGETPLATFORM
ARG TARGETOS
ARG TARGETARCH
ARG BUILDPLATFORM
ARG BUILDOS
ARG BUILDARCH
ARG BUILDVARIANT
LABEL author "Olivier Le Bris"
LABEL maintainer "zogg"
LABEL com.centurylinklabs.watchtower.enable=false
LABEL org.opencontainers.image.source "https://zogg.fr"
LABEL org.opencontainers.image.licenses MIT
ENV DEBIAN_FRONTEND noninteractive
# Install RPI-Monitor form Xavier Berger's repository
RUN apt-get -y update && \
\
apt-get install -y --no-install-recommends dirmngr apt-transport-https ca-certificates && \
apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 2C0D3C0F && \
echo deb http://www.giteduberger.fr rpimonitor/ > /etc/apt/sources.list.d/rpimonitor.list && \
apt-get -y update && \
apt-get install -y rpimonitor && \
\
apt-get clean && \
apt-get autoclean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \
\
sed -i 's/\/sys\//\/dockerhost\/sys\//g' /etc/rpimonitor/template/* && \
sed -i 's/\/etc\/os-release/\/dockerhost\/usr\/lib\/os-release/g' /etc/rpimonitor/template/version.conf && \
sed -i 's/\/proc\//\/dockerhost\/proc\//g' /etc/rpimonitor/template/* && \
#echo include=/etc/rpimonitor/template/wlan.conf >> /etc/rpimonitor/data.conf && \
sed -i '/^web.status.1.content.8.line/ d' /etc/rpimonitor/template/network.conf && \
sed -i '/^#web.status.1.content.8.line/s/^#//g' /etc/rpimonitor/template/network.conf && \
sed -i 's/\#dynamic/dynamic/g' /etc/rpimonitor/template/network.conf && \
sed -i 's/\#web.statistics/web.statistics/g' /etc/rpimonitor/template/network.conf
LABEL com.centurylinklabs.watchtower.enable=false
EXPOSE 8888
ADD work/run.sh /run.sh
RUN chmod +x /run.sh
CMD bash -C '/run.sh';'bash'
Procédure
Pour lancer la construction de l’image, il suffit de donner au script shell build.sh les droits d’éxécution puis de le lancer :
sudo chmod +x build.sh && sudo bash build.sh
Conclusion
Vous avez maintenant une image Docker compatible ARM64 à lancer sous Docker (ou avec Portainer :p).