2023-06-17 12:48:52 +02:00
|
|
|
## Get Klipper Source and Build venv
|
|
|
|
|
##
|
2024-11-09 17:41:28 +01:00
|
|
|
FROM python:3.11-bookworm AS build
|
2021-10-16 18:42:56 +02:00
|
|
|
|
2024-03-23 14:09:33 +01:00
|
|
|
RUN apt update \
|
|
|
|
|
&& apt install -y cmake \
|
|
|
|
|
&& apt clean
|
2021-10-16 18:42:56 +02:00
|
|
|
|
|
|
|
|
WORKDIR /opt
|
2024-03-23 15:49:32 +01:00
|
|
|
COPY requirements-prind.txt .
|
2024-03-23 14:09:33 +01:00
|
|
|
|
|
|
|
|
RUN python -m venv venv \
|
2024-03-23 15:49:32 +01:00
|
|
|
&& venv/bin/pip install -r requirements-prind.txt
|
2024-03-23 14:09:33 +01:00
|
|
|
|
|
|
|
|
ARG REPO=https://github.com/Klipper3d/klipper
|
|
|
|
|
ARG VERSION=master
|
2021-10-16 18:42:56 +02:00
|
|
|
|
|
|
|
|
RUN git clone ${REPO} klipper \
|
|
|
|
|
&& cd klipper \
|
2022-12-01 21:47:14 +01:00
|
|
|
&& git checkout ${VERSION} \
|
2025-01-06 14:42:17 +01:00
|
|
|
&& echo -n $(git describe --tags)-prind > klippy/.version \
|
2022-12-01 21:47:14 +01:00
|
|
|
&& rm -rf .git
|
2021-10-16 18:42:56 +02:00
|
|
|
|
2024-03-23 14:09:33 +01:00
|
|
|
RUN venv/bin/pip install -r klipper/scripts/klippy-requirements.txt \
|
2021-10-17 00:05:50 +02:00
|
|
|
&& venv/bin/python -m compileall klipper/klippy \
|
2021-10-16 23:23:33 +02:00
|
|
|
&& venv/bin/python klipper/klippy/chelper/__init__.py
|
2023-06-17 12:48:52 +02:00
|
|
|
###
|
2021-10-16 18:42:56 +02:00
|
|
|
|
2023-06-17 12:48:52 +02:00
|
|
|
|
|
|
|
|
## Klippy Runtime Image
|
|
|
|
|
##
|
2024-11-09 17:41:28 +01:00
|
|
|
FROM python:3.11-slim-bookworm AS run
|
2021-10-16 18:42:56 +02:00
|
|
|
|
2021-10-16 23:23:33 +02:00
|
|
|
WORKDIR /opt
|
2021-10-16 18:42:56 +02:00
|
|
|
RUN groupadd klipper --gid 1000 \
|
|
|
|
|
&& useradd klipper --uid 1000 --gid klipper \
|
2023-06-17 12:48:52 +02:00
|
|
|
&& usermod klipper --append --groups dialout \
|
|
|
|
|
&& usermod klipper --append --groups tty
|
2022-12-01 21:47:14 +01:00
|
|
|
RUN mkdir -p printer_data/run printer_data/gcodes printer_data/logs printer_data/config \
|
2021-10-16 23:23:33 +02:00
|
|
|
&& chown -R klipper:klipper /opt/*
|
2021-10-16 18:42:56 +02:00
|
|
|
|
2024-11-11 23:03:40 +01:00
|
|
|
COPY --chown=klipper:klipper health.py ./
|
|
|
|
|
|
2022-12-01 21:47:14 +01:00
|
|
|
COPY --chown=klipper:klipper --from=build /opt/klipper ./klipper
|
|
|
|
|
COPY --chown=klipper:klipper --from=build /opt/venv ./venv
|
|
|
|
|
|
2021-10-16 18:42:56 +02:00
|
|
|
USER klipper
|
2022-10-19 13:21:01 +02:00
|
|
|
VOLUME ["/opt/printer_data/run", "/opt/printer_data/gcodes", "/opt/printer_data/logs", "/opt/printer_data/config"]
|
2021-10-20 23:18:43 +02:00
|
|
|
ENTRYPOINT ["/opt/venv/bin/python", "klipper/klippy/klippy.py"]
|
2022-10-18 18:46:05 +02:00
|
|
|
CMD ["-I", "printer_data/run/klipper.tty", "-a", "printer_data/run/klipper.sock", "printer_data/config/printer.cfg"]
|
2023-06-17 12:48:52 +02:00
|
|
|
###
|
|
|
|
|
|
2021-10-16 18:42:56 +02:00
|
|
|
|
2023-06-17 12:48:52 +02:00
|
|
|
## Image for building MCU code including other tooling
|
|
|
|
|
##
|
2024-11-09 17:41:28 +01:00
|
|
|
FROM debian:bookworm AS tools
|
2021-10-16 23:23:33 +02:00
|
|
|
|
|
|
|
|
WORKDIR /opt
|
2022-07-08 16:30:23 +02:00
|
|
|
ARG DEBIAN_FRONTEND=noninteractive
|
2021-10-16 18:42:56 +02:00
|
|
|
RUN apt update \
|
2021-10-16 23:23:33 +02:00
|
|
|
&& apt install -y \
|
2023-02-03 11:47:20 +01:00
|
|
|
sudo \
|
2023-06-22 19:24:59 +02:00
|
|
|
virtualenv python3-dev libffi-dev build-essential pkg-config\
|
2021-10-16 23:23:33 +02:00
|
|
|
libncurses-dev \
|
|
|
|
|
avrdude gcc-avr binutils-avr avr-libc \
|
2023-02-03 13:23:22 +01:00
|
|
|
stm32flash dfu-util libnewlib-arm-none-eabi \
|
2023-06-13 22:10:01 +02:00
|
|
|
gcc-arm-none-eabi binutils-arm-none-eabi libusb-1.0-0 libusb-1.0-0-dev \
|
2022-07-08 16:30:23 +02:00
|
|
|
python3-numpy python3-matplotlib \
|
2021-10-17 14:11:32 +02:00
|
|
|
&& apt clean
|
2022-03-09 22:36:54 +01:00
|
|
|
|
2023-04-07 18:25:50 +02:00
|
|
|
COPY --from=build /opt/klipper ./klipper
|
|
|
|
|
COPY --from=build /opt/venv ./venv
|
2023-06-17 12:48:52 +02:00
|
|
|
###
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Build the klipper_mcu binary
|
|
|
|
|
##
|
2024-11-09 17:41:28 +01:00
|
|
|
FROM tools AS build-hostmcu
|
2023-06-17 12:48:52 +02:00
|
|
|
|
|
|
|
|
WORKDIR /opt
|
|
|
|
|
|
|
|
|
|
COPY config.hostmcu klipper/.config
|
|
|
|
|
RUN cd klipper \
|
|
|
|
|
&& make flash
|
|
|
|
|
###
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Runtime image for the klipper_mcu binary
|
|
|
|
|
##
|
2024-11-09 17:41:28 +01:00
|
|
|
FROM debian:bookworm-slim AS hostmcu
|
2023-06-17 12:48:52 +02:00
|
|
|
|
|
|
|
|
RUN apt update \
|
|
|
|
|
&& apt install -y gpiod \
|
|
|
|
|
&& apt clean
|
|
|
|
|
|
|
|
|
|
COPY --from=build-hostmcu /usr/local/bin/klipper_mcu /usr/local/bin/klipper_mcu
|
|
|
|
|
|
|
|
|
|
VOLUME ["/opt/printer_data/run"]
|
|
|
|
|
ENTRYPOINT ["/usr/local/bin/klipper_mcu"]
|
|
|
|
|
CMD ["-I", "/opt/printer_data/run/klipper_host_mcu.tty"]
|
|
|
|
|
###
|
|
|
|
|
|
2022-12-01 21:47:14 +01:00
|
|
|
|
2023-06-17 12:48:52 +02:00
|
|
|
## Build Simulavr and klipper.elf
|
|
|
|
|
## For manual builds, not uploaded to the docker registry
|
2024-11-09 17:41:28 +01:00
|
|
|
FROM tools AS build-simulavr
|
2022-03-09 22:36:54 +01:00
|
|
|
|
|
|
|
|
RUN apt update \
|
|
|
|
|
&& apt install -y \
|
|
|
|
|
git cmake swig \
|
|
|
|
|
python3-dev \
|
|
|
|
|
&& apt clean
|
|
|
|
|
|
|
|
|
|
WORKDIR /opt/klipper
|
|
|
|
|
COPY config.simulavr .config
|
|
|
|
|
RUN make
|
|
|
|
|
|
|
|
|
|
WORKDIR /opt
|
2022-12-01 21:47:14 +01:00
|
|
|
RUN mkdir run
|
|
|
|
|
RUN groupadd simulavr --gid 1000 \
|
|
|
|
|
&& useradd simulavr --uid 1000 --gid simulavr \
|
|
|
|
|
&& usermod simulavr --append --groups dialout
|
|
|
|
|
|
2022-03-09 22:36:54 +01:00
|
|
|
RUN git clone git://git.savannah.nongnu.org/simulavr.git \
|
|
|
|
|
&& cd simulavr \
|
|
|
|
|
&& git checkout release-1.1.0 \
|
|
|
|
|
&& make python \
|
2022-12-01 21:47:14 +01:00
|
|
|
&& make build \
|
|
|
|
|
&& chown -R simulavr:simulavr /opt/simulavr
|
2022-03-09 22:36:54 +01:00
|
|
|
|
|
|
|
|
USER simulavr
|
|
|
|
|
ENV PYTHONPATH=/opt/simulavr/build/pysimulavr/
|
2022-10-19 13:21:01 +02:00
|
|
|
VOLUME ["/opt/printer_data/run"]
|
2022-03-09 22:36:54 +01:00
|
|
|
ENTRYPOINT ["klipper/scripts/avrsim.py"]
|
2022-10-18 18:46:05 +02:00
|
|
|
CMD ["-p", "/opt/printer_data/run/simulavr.tty", "/opt/klipper/out/klipper.elf"]
|