mirror of
https://github.com/dimalo/klipper-web-control-docker.git
synced 2026-05-09 00:36:39 +02:00
update docker build
- BREAKING CHANGE: make printer.cfg the main config file, instead of klipper.cfg. existing configs need to be migrated: - copy all include statements from klipper.cfg to printer.cfg - remove klipper.cfg - add run_in_venv script to activate venv correctly, then start klipper/moonraker - add rpi_mcu config file and include in printer.cfg - add cap_add: SYS_NICE to docker-compose to run klipper_mcu - build & run klipper with python3 - precompile klipper C-Code in build stage, remove gcc from run image (https://www.klipper3d.org/Packaging.html) - remove python3 debian packages, globally install with pip instead
This commit is contained in:
12
config/host_mcu.cfg
Normal file
12
config/host_mcu.cfg
Normal file
@@ -0,0 +1,12 @@
|
||||
# https://github.com/Klipper3d/klipper/blob/master/config/sample-raspberry-pi.cfg
|
||||
# This file contains an example configuration with RPi as secondary mcu
|
||||
|
||||
# See docs/Config_Reference.md for a description of parameters.
|
||||
|
||||
# The rpi microcontroller is used as secondary.
|
||||
# Typically, both the X and Y axes
|
||||
# are connected to the main micro-controller. The rpi microcontroller is used
|
||||
# on non time-critical functions such as enclosure sensors, additional fan or
|
||||
# light sources
|
||||
[mcu host]
|
||||
serial: /tmp/klipper_host_mcu
|
||||
@@ -1,4 +0,0 @@
|
||||
[include printer.cfg]
|
||||
[include client.cfg]
|
||||
[include client_macros.cfg]
|
||||
[include calibration_macros.cfg]
|
||||
@@ -1,2 +1,7 @@
|
||||
# This is a dummy config.
|
||||
# Either mount your config from host like <config_path>:/home/klippy/.config/printer.cfg or change the contents of this file in UI to match your printer!
|
||||
# Either mount your config from host like <config_path>:/home/klippy/.config/printer.cfg or change the contents of this file in UI to match your printer!
|
||||
|
||||
[include host_mcu.cfg]
|
||||
[include client.cfg]
|
||||
[include client_macros.cfg]
|
||||
[include calibration_macros.cfg]
|
||||
|
||||
@@ -6,9 +6,12 @@ services:
|
||||
build:
|
||||
dockerfile: ./klipper/Dockerfile
|
||||
context: .
|
||||
# args:
|
||||
# DEVICE_GROUP: device
|
||||
# DEVICE_GID: 987
|
||||
# if klipper cannot connect to the printer check permissions on rpi then add the group here
|
||||
# group_add:
|
||||
# - "996"
|
||||
# - "998"
|
||||
cap_add:
|
||||
- SYS_NICE
|
||||
container_name: klipper
|
||||
ports:
|
||||
- 7125:7125
|
||||
|
||||
@@ -11,10 +11,26 @@ ARG MOONRAKER_VENV_DIR=${HOME}/moonraker-env
|
||||
|
||||
RUN useradd -d ${HOME} -ms /bin/bash ${USER}
|
||||
RUN apt-get update && \
|
||||
apt-get install -y locales git sudo wget curl gzip tar python2 virtualenv python-dev libffi-dev build-essential libncurses-dev libusb-dev gpiod python3-virtualenv python3-dev libopenjp2-7 python3-libgpiod liblmdb-dev libsodium-dev
|
||||
apt-get install -y \
|
||||
locales \
|
||||
git \
|
||||
sudo \
|
||||
wget \
|
||||
curl \
|
||||
gzip \
|
||||
tar \
|
||||
libffi-dev \
|
||||
build-essential \
|
||||
libncurses-dev \
|
||||
libusb-dev \
|
||||
gpiod \
|
||||
libopenjp2-7 \
|
||||
liblmdb-dev \
|
||||
libsodium-dev
|
||||
|
||||
RUN sed -i -e 's/# en_GB.UTF-8 UTF-8/en_GB.UTF-8 UTF-8/' /etc/locale.gen
|
||||
RUN locale-gen
|
||||
RUN python -m pip install pip -U
|
||||
|
||||
ENV LC_ALL en_GB.UTF-8
|
||||
ENV LANG en_GB.UTF-8
|
||||
@@ -25,22 +41,25 @@ WORKDIR ${HOME}
|
||||
|
||||
### Klipper setup ###
|
||||
RUN git clone --single-branch --branch ${KLIPPER_BRANCH} https://github.com/Klipper3d/klipper.git klipper
|
||||
RUN [ ! -d ${KLIPPER_VENV_DIR} ] && virtualenv -p python2 ${KLIPPER_VENV_DIR}
|
||||
RUN ${KLIPPER_VENV_DIR}/bin/python -m pip install pip -U
|
||||
RUN [ ! -d ${KLIPPER_VENV_DIR} ] && python3 -m venv ${KLIPPER_VENV_DIR}
|
||||
RUN ${KLIPPER_VENV_DIR}/bin/pip install wheel numpy
|
||||
RUN ${KLIPPER_VENV_DIR}/bin/pip install -r klipper/scripts/klippy-requirements.txt
|
||||
|
||||
COPY klipper/.config_linux /home/klippy/klipper/.config
|
||||
WORKDIR ${HOME}/klipper
|
||||
RUN ${KLIPPER_VENV_DIR}/bin/pip install -r scripts/klippy-requirements.txt
|
||||
RUN ${KLIPPER_VENV_DIR}/bin/python klippy/chelper/__init__.py
|
||||
RUN ${KLIPPER_VENV_DIR}/bin/python -m compileall klippy
|
||||
|
||||
RUN cd ${HOME}/klipper && make
|
||||
COPY klipper/.config_linux_mcu ./.config
|
||||
RUN make
|
||||
|
||||
WORKDIR ${HOME}
|
||||
# Install moonraker
|
||||
RUN git clone --single-branch --branch ${MOONRAKER_BRANCH} https://github.com/Arksine/moonraker.git moonraker
|
||||
RUN [ ! -d ${MOONRAKER_VENV_DIR} ] && python3 -m venv ${MOONRAKER_VENV_DIR}
|
||||
RUN ${MOONRAKER_VENV_DIR}/bin/python -m pip install pip -U
|
||||
RUN ${MOONRAKER_VENV_DIR}/bin/pip install wheel gpiod
|
||||
|
||||
RUN ${MOONRAKER_VENV_DIR}/bin/pip install -r moonraker/scripts/moonraker-requirements.txt
|
||||
WORKDIR ${HOME}/moonraker
|
||||
RUN ${MOONRAKER_VENV_DIR}/bin/pip install -r scripts/moonraker-requirements.txt
|
||||
|
||||
FROM python:3.10-slim-bullseye as image
|
||||
|
||||
@@ -49,7 +68,6 @@ ARG DEBIAN_FRONTEND=noninteractive
|
||||
RUN apt-get update && \
|
||||
apt-get install -y \
|
||||
curl \
|
||||
gcc \
|
||||
git \
|
||||
gpiod \
|
||||
iproute2 \
|
||||
@@ -61,10 +79,6 @@ RUN apt-get update && \
|
||||
libssl-dev \
|
||||
libtiff5 \
|
||||
locales \
|
||||
python2 \
|
||||
python3-libgpiod \
|
||||
python3-numpy \
|
||||
python3-matplotlib \
|
||||
rsync \
|
||||
supervisor \
|
||||
zlib1g-dev && \
|
||||
@@ -95,7 +109,7 @@ RUN useradd --user-group --no-log-init --shell /bin/false -m -d ${HOME} ${USER}
|
||||
usermod -a -G dialout ${USER} && \
|
||||
mkdir -p /var/log/supervisor && \
|
||||
mkdir -p /var/log/klipper && chown ${USER}:${USER} /var/log/klipper ${HOME} && \
|
||||
pip install --no-cache supervisord-dependent-startup gpiod && \
|
||||
pip install --no-cache supervisord-dependent-startup gpiod numpy matplotlib && \
|
||||
mkdir -p /usr/lib/python3 && \
|
||||
ln -s /usr/local/lib/python3.10/site-packages /usr/lib/python3/dist-packages
|
||||
|
||||
@@ -117,6 +131,7 @@ COPY --chown=${USER}:${USER} --from=builder ${KLIPPER_VENV_DIR} ${KLIPPER_VENV_D
|
||||
COPY --chown=${USER}:${USER} --from=builder ${HOME}/moonraker ${HOME}/moonraker
|
||||
COPY --chown=${USER}:${USER} --from=builder ${MOONRAKER_VENV_DIR} ${MOONRAKER_VENV_DIR}
|
||||
COPY --chown=${USER}:${USER} config ${CONFIG_DIR}
|
||||
COPY --chown=${USER}:${USER} klipper/run_in_venv /usr/local/bin/run_in_venv
|
||||
|
||||
COPY klipper/supervisord.conf /etc/supervisord/conf.d/supervisord.conf
|
||||
COPY klipper/*.ini /etc/supervisord/
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM python:3.10
|
||||
FROM python:3.10-bullseye
|
||||
|
||||
ARG DEBIAN_FRONTEND=noninteractive
|
||||
ARG KLIPPER_BRANCH="master"
|
||||
@@ -7,18 +7,28 @@ ARG USER=klippy
|
||||
ARG HOME=/home/${USER}
|
||||
ARG KLIPPER_VENV_DIR=${HOME}/klippy-env
|
||||
|
||||
ENV PKGLIST="virtualenv python-dev libffi-dev build-essential"
|
||||
ENV PKGLIST="libffi-dev build-essential"
|
||||
ENV PKGLIST="${PKGLIST} libncurses-dev"
|
||||
ENV PKGLIST="${PKGLIST} libusb-dev"
|
||||
ENV PKGLIST="${PKGLIST} avrdude gcc-avr binutils-avr avr-libc"
|
||||
ENV PKGLIST="${PKGLIST} stm32flash libnewlib-arm-none-eabi"
|
||||
ENV PKGLIST="${PKGLIST} gcc-arm-none-eabi binutils-arm-none-eabi libusb-1.0"
|
||||
ENV PKGLIST="${PKGLIST} gcc-arm-none-eabi binutils-arm-none-eabi libusb-1.0 pkg-config"
|
||||
|
||||
RUN useradd -d ${HOME} -ms /bin/bash ${USER}
|
||||
RUN apt-get update && \
|
||||
apt-get install -y locales git sudo wget curl gzip tar ${PKGLIST}
|
||||
apt-get install -y \
|
||||
locales \
|
||||
git \
|
||||
sudo \
|
||||
wget \
|
||||
curl \
|
||||
gzip \
|
||||
tar \
|
||||
${PKGLIST}
|
||||
|
||||
RUN sed -i -e 's/# en_GB.UTF-8 UTF-8/en_GB.UTF-8 UTF-8/' /etc/locale.gen
|
||||
RUN locale-gen
|
||||
RUN python -m pip install pip -U
|
||||
|
||||
ENV LC_ALL en_GB.UTF-8
|
||||
ENV LANG en_GB.UTF-8
|
||||
@@ -29,10 +39,13 @@ WORKDIR ${HOME}
|
||||
|
||||
### Klipper setup ###
|
||||
RUN git clone --single-branch --branch ${KLIPPER_BRANCH} https://github.com/Klipper3d/klipper.git klipper
|
||||
RUN [ ! -d ${KLIPPER_VENV_DIR} ] && virtualenv -p 2 ${KLIPPER_VENV_DIR}
|
||||
RUN ${KLIPPER_VENV_DIR}/bin/python -m pip install pip -U
|
||||
RUN [ ! -d ${KLIPPER_VENV_DIR} ] && python3 -m venv ${KLIPPER_VENV_DIR}
|
||||
RUN ${KLIPPER_VENV_DIR}/bin/pip install wheel
|
||||
RUN ${KLIPPER_VENV_DIR}/bin/pip install -r klipper/scripts/klippy-requirements.txt
|
||||
|
||||
WORKDIR ${HOME}/klipper
|
||||
RUN ${KLIPPER_VENV_DIR}/bin/pip install -r scripts/klippy-requirements.txt
|
||||
RUN ${KLIPPER_VENV_DIR}/bin/python klippy/chelper/__init__.py
|
||||
RUN ${KLIPPER_VENV_DIR}/bin/python -m compileall klippy
|
||||
|
||||
WORKDIR ${HOME}/klipper
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
|
||||
[program:klipper]
|
||||
user=klippy
|
||||
command=/home/klippy/klippy-env/bin/python /home/klippy/klipper/klippy/klippy.py -a /tmp/klippy_uds -l /var/log/klipper/klipper.log /home/klippy/.config/klipper.cfg
|
||||
environment=USER=klippy,HOME=/home/klippy,PYTHONHOME=/home/klippy/klippy-env
|
||||
command=run_in_venv /home/klippy/klippy-env python /home/klippy/klipper/klippy/klippy.py -a /tmp/klippy_uds -l /var/log/klipper/klipper.log /home/klippy/.config/printer.cfg
|
||||
environment=USER=klippy,HOME=/home/klippy
|
||||
stdout_logfile=/dev/fd/1
|
||||
stdout_logfile_maxbytes = 0
|
||||
stderr_logfile=/dev/fd/2
|
||||
|
||||
@@ -6,4 +6,5 @@ stdout_logfile_maxbytes = 0
|
||||
stderr_logfile=/dev/fd/2
|
||||
stderr_logfile_maxbytes = 0
|
||||
autorestart=true
|
||||
autostart=true
|
||||
autostart=false
|
||||
dependent_startup=true
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[program:moonraker]
|
||||
user=klippy
|
||||
command=/home/klippy/moonraker-env/bin/python /home/klippy/moonraker/moonraker/moonraker.py -l /var/log/klipper/moonraker.log -c /home/klippy/.config/moonraker.conf
|
||||
command=run_in_venv /home/klippy/moonraker-env python /home/klippy/moonraker/moonraker/moonraker.py -l /var/log/klipper/moonraker.log -c /home/klippy/.config/moonraker.conf
|
||||
environment=USER=klippy,HOME=/home/klippy
|
||||
stdout_logfile=/dev/fd/1
|
||||
stdout_logfile_maxbytes = 0
|
||||
|
||||
11
klipper/run_in_venv
Executable file
11
klipper/run_in_venv
Executable file
@@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
VENV=$1
|
||||
if [ -z $VENV ]; then
|
||||
echo "usage: run_in_venv [virtualenv_path] CMDS"
|
||||
exit 1
|
||||
fi
|
||||
. ${VENV}/bin/activate
|
||||
shift 1
|
||||
echo "Executing $@ in ${VENV}"
|
||||
exec "$@"
|
||||
deactivate
|
||||
Reference in New Issue
Block a user