DashMachine
DashMachine copied to clipboard
Compatability with raspberry pi
Hi,
I tried running the docker line from the README on a raspberry pi running raspbian
docker create
--name=dashmachine
-p 5000:5000
-v path/to/data:/DashMachine/dashmachine/user_data
--restart unless-stopped
rmountjoy/dashmachine:latest
using my own custom path (empty folder) in place of path/to/data. The docker container seems to immediately exit. Checking the logs (docker logs --tail 50 --follow --timestamps), I get the following error:
standard_init_linux.go:211: exec user process caused "exec format error"
using @nicoulaj's updates didn't work for me but I'm no docker expert; I probably missed something. This thread on reddit worked for me so putting the steps that worked for me as reference.
In the terminal run:
git clone https://git.wolf-house.net/ross/DashMachine.git Use your text editor of choice to edit the Dockerfile to be:
FROM arm32v7/python:3.8-slim
RUN rm /bin/sh && ln -s /bin/bash /bin/sh
RUN apt-get update
&& apt-get install gcc git -y
&& apt-get install libffi-dev \
&& apt-get clean
COPY requirements.txt /tmp/ RUN pip install --requirement /tmp/requirements.txt COPY . /tmp/ COPY ./ DashMachine WORKDIR DashMachine EXPOSE 5000 CMD ["python", "run.py"] Run sudo docker build ./ and wait.
Once the image is built, rename it to whatever using docker image tag command.
Example: docker image tag c12345678910 user/dashmachine-rpi:latest
Optional if you have docker-compose installed: create a docker-compose.yml file (remove the # comment since it can cause problems in docker #)
version: '2'
services: dashmachine: image: volcan96/dashmachine-rpi:latest #this is the image name you gave # restart: unless-stopped volumes: - /home/pi/DashMachine/_data:/dashmachine/dashmachine/user_data #this stores any image user data in a directory to persist it# ports: - 5000:5000 environment: - PUID=1000 - PGID=1000 - TZ=America/Los_Angeles Finally, run docker-compose up in the terminal
You can use github actions to build cross platform images with buildx. I used it in my project and it works like a charm. Example config
Hi @rmountjoy92
Thanks for the comment, I grepped installing "gcc, git and libffi-dev" part. I run this command on other arm board and left the first line as original file. python:3.8-slim is already platform-free.
FROM python:3.8-slim
FROM python:3.8-slim
RUN apt-get update -q \
&& apt-get install --no-install-recommends -qy \
inetutils-ping \
&& rm -rf /var/lib/apt/lists/*
RUN rm /bin/sh && ln -s /bin/bash /bin/sh
RUN apt-get update \
&& apt-get install gcc git -y \
&& apt-get install libffi-dev \
&& apt-get clean
COPY [ "requirements.txt", "/dashmachine/" ]
WORKDIR /dashmachine
RUN pip install --no-cache-dir --progress-bar off -r requirements.txt
COPY [ ".", "/dashmachine/" ]
ENV PRODUCTION=true
EXPOSE 5000
VOLUME /dashmachine/dashmachine/user_data
CMD [ "gunicorn", "--bind", "0.0.0.0:5000", "wsgi:app" ]
My build command;
docker build . -t dashmachine
Here is my docker-compose.yml
version: "3"
services:
dashmachine:
image: dashmachine
container_name: dashmachine
restart: unless-stopped
volumes:
- /data/config/dashmachine:/dashmachine/dashmachine/user_data
ports:
- "5000:5000"
network_mode: "host"
networks:
default:
external:
name: skynet
When building the image on my Raspberry PI 3B+, I keep getting the following error:
pip install --no-cache-dir --progress-bar off -r requirements.txt
Traceback (most recent call last):
File "/usr/local/bin/pip", line 3, in <module>
import re
File "/usr/local/lib/python3.8/re.py", line 337, in <module>
import copyreg
ValueError: source code string cannot contain null bytes
Have you run into similar issue?
EDIT: turns out it was an issue with the python:3.8.5-slim image! Downgrading to python:3.8.4-slim and running the Dockerfile.arm from this commit solved the issue
If you just want an image to work with, use failed2run/dashmachine in your code.
Note: Unfortunatly the image is only compatible with the 64-bit version of ARM. This does not have to be an issue, since the Raspberry Pi is capable of ARM64, but you will need Ubuntu/Ubuntu Server or the beta version of Raspberry Pi OS to run it.
EDIT: Using a slightly modified Dockerfile I was able to build the image for all versions of ARM, including the 32-bit version.
I was able to build and run the image on an ARM64 Raspberry Pi 4 with 8GB memory:
uname -a
Linux raspberry 5.4.0-1026-raspi #29-Ubuntu SMP PREEMPT
Mon Dec 14 17:01:16 UTC 2020 aarch64 aarch64 aarch64 GNU/Linux
git clone https://github.com/rmountjoy92/DashMachine.git
cd DashMachine
docker build . -t dashmachine
docker run --rm --name dashmachine -p 5000:5000 dashmachine
# Start webbrowser to raspberrypi port 5000
# Login with admin:admin
docker-compose.yml
version: "3"
services:
dashmachine:
image: dashmachine
container_name: dashmachine
restart: always
networks:
- web
ports:
- 5000:5000
volumes:
- $PWD/dashmachine_data:/dashmachine/dashmachine/user_data
networks:
web:
driver: bridge
docker-compose up
Thanks!
For 'production' on a RPi4 I avoid the local git repo with:
Dockerfile
FROM ubuntu as builder
RUN apt-get update -q \
&& apt-get install -y \
git \
&& rm -rf /var/lib/apt/lists/*
RUN git clone --depth 1 https://github.com/rmountjoy92/DashMachine.git /git
FROM python:3.8-slim
RUN apt-get update -q \
&& apt-get install --no-install-recommends -qy \
inetutils-ping libffi-dev build-essential libjpeg-dev zlib1g-dev libtiff-dev \
&& rm -rf /var/lib/apt/lists/*
COPY --from=builder /git/. /dashmachine/
WORKDIR /dashmachine
RUN pip install --no-cache-dir --progress-bar off -r requirements.txt
ENV PRODUCTION=true
EXPOSE 5000
VOLUME /dashmachine/dashmachine/user_data
CMD [ "gunicorn", "--bind", "0.0.0.0:5000", "wsgi:app" ]
docker-compose.yml
version: "3.6"
services:
dash:
build: .
restart: always
ports:
- 5000:5000
volumes:
- ./data:/dashmachine/dashmachine/user_data
docker-compose up -d
#update with 'docker-compose build'
Thanks @muebau. This works perfect and platform independent.
Thank you @rmountjoy92, @mabayhan and @muebau for your suggestions and Dockerfile examples! I was able to build a very compact Docker image after reviewing your comments.
I had tried to use the original Dockerfile, but it wasn't working on Raspberry Pi 4 (32bit). It was complaining about not finding gcc initially and the build would fail.. so I knew dependencies were missing but wasn't sure which ones. With your help I was able to get a working Dockerfile together!
I also found the below dependency link helpful, as Pillow kept failing to build. It has a lot of dependencies, and your examples were encouraging as I knew I wouldn't have to include ALL the dependencies. But it was a challenge to isolate which ones, to ensure the smallest image possible is built. Pillow dependencies are summarized here (and then the section, Prerequisites for Ubuntu 16.04 LTS - 20.04 LTS....).
I originally made this sole change to the Dockerfile, and while the image did work, it created a HUGE Docker image (747MB):
- Change FROM python:3.8-slim to FROM arm32v7/python on line 1 of the Dockerfile
Now with the below Dockerfile, inspired by your posts, it has created a Docker image of only 289MB, about 61% smaller! Thank you so very much. I am sharing this in case it may be helpful to others. I am using a Raspberry Pi 4, 32bit, running Raspbian OS (buster).
FROM python:3.8-slim
RUN apt-get update -q \
&& apt-get install --no-install-recommends -qy \
inetutils-ping \
&& rm -rf /var/lib/apt/lists/*
RUN rm /bin/sh && ln -s /bin/bash /bin/sh
RUN apt-get update \
&& apt-get install libjpeg-dev zlib1g-dev -y \
&& apt-get install gcc git -y \
&& apt-get install libffi-dev \
&& apt-get clean
COPY [ "requirements.txt", "/dashmachine/" ]
WORKDIR /dashmachine
RUN pip install --no-cache-dir --progress-bar off -r requirements.txt
COPY [ ".", "/dashmachine/" ]
ENV PRODUCTION=true
EXPOSE 5000
VOLUME /dashmachine/dashmachine/user_data
CMD [ "gunicorn", "--bind", "0.0.0.0:5000", "wsgi:app" ]
To create the image, I run the following command in the same directory that has the git code cloned:
docker build -t dashmachine .
By the way, I initially tried the master branch, but I learned after watching this, which is mentioned on the README.md of the Github page for DashMachine, that the develop branch had an easier configuration process to add services to the homepage, and it also had more image icons for more services! So I followed these steps to get the develop branch (if this is obvious, my apologies, but sharing if others may benefit):
- Browse to the develop branch, https://github.com/rmountjoy92/DashMachine/tree/develop
- Click the green "Code" button on that page, copy the git clone command and paste it into my Raspberry Pi terminal: git clone https://github.com/rmountjoy92/DashMachine.git
- cd into that directory where the code was cloned, then run the above docker build command
- About 20 minutes later, a small Docker image is created & ready to use with Docker. :)
Thanks for DashMachine, @rmountjoy92!!!
Hi @rmountjoy92 Hi @rmountjoy92 FROM python:3.8-slim
FROM python:3.8-slim ... My build command; ```shell docker build . -t dashmachine
Here is my docker-compose.yml ...
Hi, I realize this is an older comment but it seems this project still isn't cross platform and it seems like your code is no longer working for me. I'm on raspberry pi4 with raspbian Lite OS.
I suppose the failed2run image will work, but I wondered if this is the recommended way?