149 lines
4.4 KiB
Docker
149 lines
4.4 KiB
Docker
#FROM lpenz/devuan-beowulf-armhf-minbase
|
|
FROM dyne/devuan:beowulf
|
|
SHELL ["/bin/bash", "-c"]
|
|
|
|
RUN echo "deb http://deb.devuan.org/merged/ beowulf main contrib non-free" > /etc/apt/sources.list
|
|
|
|
|
|
ARG KLIPPER_BRANCH="work-python3-20200612"
|
|
ENV KLIPPER_BRANCH=${KLIPPER_BRANCH}
|
|
|
|
ARG PRINTER_CFG="printer.cfg"
|
|
ENV PRINTER_CFG=${PRINTER_CFG}
|
|
|
|
ARG KLIPPER_HOME="/octo_printer"
|
|
ENV KLIPPER_HOME=${KLIPPER_HOME}
|
|
|
|
ARG KLIPPER_SERIAL="/hostdevices/ttyUSB0"
|
|
ENV KLIPPER_SERIAL=${KLIPPER_SERIAL}
|
|
|
|
ARG OCTO_PRINTER="/tmp"
|
|
ENV OCTO_PRINTER=${OCTO_PRINTER}
|
|
#RUN export OCTO_DIR=$(dirname ${OCTO_PRINTER}); mkdir ${OCTO_DIR} && chgrp dialout ${OCTO_DIR}
|
|
|
|
# SER2NET config string
|
|
ENV SER2NET_CONFIG "9999:raw:0:${OCTO_PRINTER}/printer:115200 8DATABITS NONE 1STOPBIT -XONXOFF LOCAL -RTSCTS"
|
|
|
|
ENV PYTHONDIR "/home/klippy/klippy-env"
|
|
|
|
RUN apt-get update
|
|
RUN apt-get install --no-install-recommends --yes apt-utils sudo python3-pip python3-wheel ser2net procps vim-tiny
|
|
|
|
# Packages for python cffi
|
|
ENV PKGLIST "python3-venv python3 python3-dev libffi-dev build-essential git"
|
|
RUN apt-get install --no-install-recommends --yes ${PKGLIST}
|
|
|
|
# kconfig requirements
|
|
ENV PKGLIST "${PKGLIST} libncurses-dev"
|
|
RUN apt-get install --no-install-recommends --yes ${PKGLIST}
|
|
|
|
# hub-ctrl
|
|
ENV PKGLIST "${PKGLIST} libusb-dev"
|
|
RUN apt-get install --no-install-recommends --yes ${PKGLIST}
|
|
|
|
# AVR chip installation and building
|
|
ENV PKGLIST "${PKGLIST} avrdude gcc-avr binutils-avr avr-libc"
|
|
RUN apt-get install --no-install-recommends --yes ${PKGLIST}
|
|
|
|
# ARM chip installation and building
|
|
ENV PKGLIST "${PKGLIST} stm32flash dfu-util libnewlib-arm-none-eabi"
|
|
ENV PKGLIST "${PKGLIST} gcc-arm-none-eabi binutils-arm-none-eabi libusb-1.0"
|
|
RUN apt-get install --no-install-recommends --yes ${PKGLIST}
|
|
|
|
|
|
|
|
# Update system package info
|
|
#RUN apt-get install --no-install-recommends --yes ${PKGLIST}
|
|
RUN apt-get autoclean
|
|
|
|
RUN echo -e '[global]\n\
|
|
extra-index-url=https://www.piwheels.org/simple'\
|
|
>> /etc/pip.conf && cat /etc/pip.conf
|
|
|
|
# Create user
|
|
RUN useradd -ms /bin/bash klippy && adduser klippy dialout
|
|
|
|
# Create the shared volume mount point
|
|
RUN mkdir -p ${KLIPPER_HOME}
|
|
RUN chown -R klippy:klippy ${KLIPPER_HOME}
|
|
|
|
USER klippy
|
|
|
|
|
|
#This fixes issues with the volume command setting wrong permissions
|
|
RUN mkdir -p /home/klippy/.config/klipper/printer/
|
|
RUN mkdir -p /home/klippy/.config/klipper/firmware/
|
|
|
|
|
|
### Klipper setup ###
|
|
WORKDIR /home/klippy
|
|
|
|
USER root
|
|
RUN mkdir -p /etc/sudoers.d/
|
|
RUN echo 'klippy ALL=(ALL:ALL) NOPASSWD: ALL' > /etc/sudoers.d/klippy && \
|
|
chown klippy:klippy -R /home/klippy
|
|
#chown klippy:klippy -R klipper
|
|
|
|
|
|
USER klippy
|
|
#RUN ./klipper/scripts/install-octopi.sh
|
|
#----------------------------------------------------------------------------
|
|
|
|
## Download the klipper git repo and checkout the python3 branch
|
|
WORKDIR /home/klippy
|
|
ENV SRCDIR /home/klippy/klipper
|
|
RUN git clone --branch ${KLIPPER_BRANCH} --single-branch https://github.com/KevinOConnor/klipper.git ${SRCDIR}
|
|
|
|
COPY klipper_cfg/firmware/config ${SRCDIR}/.config
|
|
|
|
WORKDIR ${SRCDIR}
|
|
RUN make
|
|
#RUN make flash FLASH_DEVICE=${KLIPPER_SERIAL}
|
|
|
|
RUN cp out/klipper.elf.hex /home/klippy/.config/klipper/firmware/
|
|
|
|
## Create python virtual environment
|
|
# Create virtualenv
|
|
WORKDIR /home/klippy
|
|
|
|
#COPY klipper_cfg/printer/${PRINTER_CFG} /home/klippy/.config/klipper/printer/
|
|
|
|
ENV VIRTUAL_ENV=${PYTHONDIR}
|
|
RUN python3 -m venv $VIRTUAL_ENV
|
|
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
|
|
|
|
RUN pip3 install -r ${SRCDIR}/scripts/klippy-requirements.txt
|
|
|
|
|
|
## Install startup script
|
|
#USER root
|
|
ENV INIT_FILE /etc/init.d/klipper
|
|
#ENV INIT_FILE /tmp/init_klipper
|
|
RUN sudo cp ${SRCDIR}/scripts/klipper-start.sh ${INIT_FILE}
|
|
RUN sudo update-rc.d klipper defaults
|
|
|
|
## Install startup script config
|
|
#ENV DEFAULTS_FILE /etc/default/klipper
|
|
ENV DEFAULTS_FILE /tmp/default_klipper
|
|
|
|
RUN sudo echo '# Configuration for /etc/init.d/klipper\n\
|
|
\n\
|
|
KLIPPER_USER='$USER'\n\
|
|
\n\
|
|
KLIPPER_EXEC='${PYTHONDIR}/bin/python3'\n\
|
|
\n\
|
|
KLIPPER_ARGS='${SRCDIR}/klippy/klippy.py /home/klippy/.config/klipper/printer/${PRINTER_CFG} -l ${KLIPPER_HOME}/klippy.log -I ${OCTO_PRINTER}/printer'\n\
|
|
\n '\
|
|
>> ${DEFAULTS_FILE}
|
|
|
|
#VOLUME /home/klippy/.config
|
|
|
|
# Start host software
|
|
#RUN sudo /etc/init.d/klipper restart
|
|
#--------------------------------------------------
|
|
|
|
COPY bin /home/klippy/bin/
|
|
|
|
#CMD ["${PYTHONDIR}/bin/python3", "${SRCDIR}/klippy/klippy.py", "/home/klippy/.config/klipper/printer/${PRINTER_CFG}", "--logfile", "${KLIPPER_HOME}/klippy.log", "--input-tty", "${OCTO_PRINTER}/printer"]
|
|
CMD ["/home/klippy/bin/run.sh"]
|