Compare commits

...

42 Commits

Author SHA1 Message Date
Siwat Sirichai 2ea8df2791 Update 'Dockerfile' 2023-01-14 14:34:25 +07:00
Siwat Sirichai 61ab52d882 Update 'Dockerfile' 2023-01-05 13:26:39 +07:00
Siwat Sirichai bf4ff4114d Update 'Dockerfile' 2023-01-03 00:38:52 +07:00
Siwat Sirichai 5ac8dcb4e8 Update 'Jenkinsfile' 2023-01-03 00:37:15 +07:00
Siwat Sirichai f442d97c11 Update 'Dockerfile' 2023-01-03 00:35:23 +07:00
Siwat Sirichai 2e1ec40242 Update 'README.md' 2023-01-03 00:31:28 +07:00
Siwat Sirichai 7a0a23f604 Update 'README.md' 2023-01-03 00:31:13 +07:00
Siwat Sirichai 1036fb18db Update 'Dockerfile' 2022-11-25 20:07:14 +07:00
Siwat Sirichai c0d73a3db4 add creality cloud plugin 2022-06-12 02:52:52 +07:00
Siwat Sirichai 90484f6571 Update 'Dockerfile' 2022-06-06 22:01:49 +07:00
Siwat Sirichai 93126ed352 Update 'start.py' 2022-06-06 21:47:40 +07:00
Siwat Sirichai 61fe2351b8 Update 'printer.cfg' 2022-05-13 13:45:18 +07:00
Siwat Sirichai cd81781927 Update 'octoprint_config/config.txt' 2022-05-11 23:33:08 +07:00
Siwat Sirichai 167aa4c787 change from TSD to Obico 2022-05-10 16:53:25 +07:00
Siwat Sirichai d6bec18198 Update printer.cfg 2022-05-06 14:06:29 +07:00
Siwat Sirichai 5efc9cd49a Merge branch 'ender3s1' of https://git.siwatsystem.com/satitchula-printfarm/octoprint-klipper-docker into ender3s1 2022-05-06 14:00:42 +07:00
Siwat Sirichai 95f55b9c45 add config and plugins 2022-05-06 13:59:42 +07:00
Siwat Sirichai b6fa2cf98a Update 'Dockerfile' 2022-05-04 12:07:46 +07:00
Siwat Sirichai 3f034d6e3a Update 'Dockerfile' 2022-05-03 20:08:17 +07:00
Siwat Sirichai 0389d5a53a Update 'printer.cfg' 2022-05-03 20:04:47 +07:00
Siwat Sirichai 819886ab8a Update 'printer.cfg' 2022-05-01 20:00:27 +07:00
Siwat Sirichai 8667fb5185 Update 'printer.cfg' 2022-05-01 12:07:48 +07:00
Siwat Sirichai 0f57a36107 Update 'printer.cfg' 2022-05-01 12:00:41 +07:00
Siwat Sirichai b31694361e Update 'Dockerfile' 2022-05-01 11:56:33 +07:00
Siwat Sirichai b25fd88bea Update 'start.sh' 2022-05-01 11:53:56 +07:00
Siwat Sirichai ade3118e5d Update 'printer.cfg' 2022-04-30 17:19:43 +07:00
Siwat Sirichai 99c949c2f9 remove temp sensor from mcu 2022-04-30 13:51:13 +07:00
Siwat Sirichai 4f42862a91 add ffmpeg to container 2022-04-09 11:20:26 +07:00
Siwat Sirichai b31b95458b set permission on bootup 2022-04-09 10:56:23 +07:00
Siwat Sirichai 902b9afadf remove temperature config for rpi cause we are not using rpi 2022-04-08 15:44:26 +07:00
Siwat Sirichai 8c512f0515 remove unit 2022-04-07 23:35:01 +07:00
Siwat Sirichai 256adff870 add unit config file to container 2022-04-07 22:54:17 +07:00
Siwat Sirichai bde23ac436 change tag to focal 2022-04-07 22:49:52 +07:00
Siwat Sirichai 46175997e3 add unit proxy on port 80 2022-04-07 22:47:54 +07:00
Siwat Sirichai 998f9a6ad8 drop mjpeg streamer 2022-04-07 22:18:32 +07:00
Siwat Sirichai df5d019877 add automatic default configuration upload 2022-04-07 21:25:02 +07:00
Siwat Sirichai 559e0f7575 systemd cleanup 2022-04-07 21:15:37 +07:00
Siwat Sirichai 356af5651c remove systemctl state 2022-04-07 21:09:15 +07:00
Siwat Sirichai 7c3f30c652 upgrade to python 3 2022-04-07 21:04:56 +07:00
Siwat Sirichai 1285bd8503 add printer.cfg 2022-04-07 21:02:30 +07:00
Siwat Sirichai e5f4f78560 switch to siwatinc baseimage 2022-04-07 21:02:23 +07:00
Siwat Sirichai 455fc1143b add Jenkinsfile 2022-04-07 20:47:22 +07:00
9 changed files with 309 additions and 101 deletions

View File

@ -1,7 +1,7 @@
FROM ubuntu:18.04
FROM ghcr.io/siwatinc/siwat-ubuntubaseimage:focal
ARG DEBIAN_FRONTEND=noninteractive
ENV TZ=America/New_York
ENV TZ=Asia/Bangkok
RUN apt-get update && apt-get install -y \
cmake \
@ -10,14 +10,16 @@ RUN apt-get update && apt-get install -y \
unzip \
psmisc \
git \
python-virtualenv \
python3-virtualenv \
virtualenv \
python-dev \
python3-dev \
libffi-dev \
build-essential \
tzdata \
zlib1g-dev \
libjpeg-dev
libjpeg-dev \
ffmpeg \
iputils-ping
EXPOSE 5000
@ -39,7 +41,6 @@ RUN git clone --branch $tag https://github.com/foosel/OctoPrint.git /opt/octopri
&& ./venv/bin/pip install .
RUN /opt/octoprint/venv/bin/python -m pip install \
https://github.com/AlexVerrico/Octoprint-Display-ETA/archive/master.zip \
https://github.com/1r0b1n0/OctoPrint-Tempsgraph/archive/master.zip \
https://github.com/tpmullan/OctoPrint-DetailedProgress/archive/master.zip \
https://github.com/AliceGrey/OctoprintKlipperPlugin/archive/master.zip \
@ -48,13 +49,21 @@ https://github.com/jneilliii/OctoPrint-BedLevelVisualizer/archive/master.zip \
https://github.com/OctoPrint/OctoPrint-MQTT/archive/master.zip \
https://github.com/birkbjo/OctoPrint-Themeify/archive/master.zip \
https://github.com/jneilliii/OctoPrint-Python3PluginCompatibilityCheck/archive/master.zip \
https://github.com/OllisGit/OctoPrint-PrintJobHistory/releases/latest/download/master.zip \
https://github.com/marian42/octoprint-preheat/archive/master.zip \
https://github.com/OllisGit/OctoPrint-FilamentManager/releases/latest/download/master.zip \
https://github.com/OllisGit/OctoPrint-DisplayLayerProgress/releases/latest/download/master.zip \
https://github.com/jneilliii/OctoPrint-UltimakerFormatPackage/archive/master.zip \
https://github.com/jneilliii/OctoPrint-ConsolidateTempControl/archive/master.zip \
https://github.com/LazeMSS/OctoPrint-UICustomizer/archive/main.zip
https://github.com/eyal0/OctoPrint-PrintTimeGenius/archive/master.zip \
https://github.com/jneilliii/OctoPrint-PrusaSlicerThumbnails/archive/master.zip \
https://gitlab.com/mosaic-mfg/canvas-plugin/-/archive/master/canvas-plugin-master.zip \
https://github.com/costas-basdekis/MarlinGcodeDocumentation/archive/master.zip \
https://github.com/crealitycloud/OctoPrint-Crealitycloud/archive/master.zip \
https://github.com/crysxd/OctoApp-Plugin/archive/refs/heads/release.zip \
https://github.com/paukstelis/OctoPrint-Cancelobject/archive/master.zip \
https://github.com/OllisGit/OctoPrint-CostEstimation/releases/latest/download/master.zip \
https://github.com/eyal0/OctoPrint-MultipleUpload/archive/master.zip \
https://gitlab.com/mosaic-mfg/canvas-plugin/-/archive/3.0.3/canvas-plugin-3.0.3.zip \
https://github.com/wgcv/RewriteM600/archive/master.zip \
https://github.com/TheSpaghettiDetective/OctoPrint-Obico/archive/master.zip
VOLUME /home/octoprint/.octoprint
@ -69,6 +78,7 @@ COPY klippy.sudoers /etc/sudoers.d/klippy
RUN useradd -ms /bin/bash klippy
# This is to allow the install script to run without error
RUN rm -f /bin/systemctl
RUN ln -s /bin/true /bin/systemctl
USER octoprint
@ -86,5 +96,6 @@ RUN rm -f /bin/systemctl
COPY start.py /
COPY runklipper.py /
CMD ["/start.py"]
COPY start.sh /
COPY printer.cfg /
CMD bash /start.sh

27
Jenkinsfile vendored Normal file
View File

@ -0,0 +1,27 @@
pipeline {
agent any
stages {
stage('Clone') {
steps {
git branch: 'ender3s1', url: 'https://git.siwatsystem.com/satitchula-printfarm/octoprint-klipper-docker'
}
}
stage('Build Docker Image') {
steps {
script {
image = docker.build("siwatinc/octoprint-klipper:ender3s1","./ --no-cache")
}
}
}
stage('Publish Docker Image') {
steps {
script {
docker.withRegistry("https://ghcr.io/v2") {
image.push()
}
}
}
}
}
}

View File

@ -1,64 +1,3 @@
# OctoPrint-Klipper
*I no longer use this image (using [Kiauh] instead) so this will be rarely updated.*
My version of a Docker image for running [OctoPrint] and [Klipper] in a single container. Includes a few plugins I find useful.
Big thanks to [sillyfrog](https://github.com/sillyfrog) for laying the groundwork for this image.
This is very much written for my purposes, so you'll likely need to modify it for your setup. I've been using it for a while now and it's going well. I've successfully run it on these platforms:
* Orange Pi Zero 512MB
* AtomicPi
* Raspberry Pi 4B 1GB (current source of `arm` images)
## Running the container
Create a directory on your host that will persist config files. I use `/home/docker/octoprint-klipper`.
Pull the image. Until I figure out multi platform aware images, you need to specify your arch. Both `arm` and `amd64` images are on DockerHub. If using Raspberry Pi or similar use `arm` in place of `[tag]`.
```shell
docker pull seanauff/octoprint-klipper:[tag]
```
Start the container once to populate your config folder:
```
docker run -d --name octoprint-klipper -e TZ=America/New_York -v /home/docker/octoprint-klipper:/home/octoprint/.octoprint --device /dev/ttyUSB0:/dev/ttyUSB0 -p 5000:5000 seanauff/octoprint-klipper:[tag]
```
Stop the container, and modify your [Klipper] `printer.cfg` and [Octoprint] `config.yaml` in the config directory as needed.
Restart the container.
A sample docker-compose file is also provided.
If you have any questions, feel free to log an issue on this project, and I'll see if I can help.
## Reconnecting to MCU after board power cycle
Depending on your power situation, removing power from the printer main board will interrupt the serial connection. I had to give my container some more permissions in order to detect the connection again without restarting the entire container. There is some discussion [here](https://github.com/moby/moby/issues/35359) and [here](https://www.losant.com/blog/how-to-access-serial-devices-in-docker).
## Updates
The easiest way to update is to pull the latest image and recreate the container. You could also build the image yourself to get the latest updates. I have had success in using the Octoprint built in updater to upgrade plugins, as well as install new ones. Any upgrades conducted in this manner will be lost upon recreation of the container.
## Build the image yourself
The DockerHub images may not be as up to date as the repo (`amd64` is autobuilt, but not `arm`), so you can ensure you have the latest by building yourself.
Clone the repository and build the image:
```shell
git clone https://github.com/seanauff/OctoPrint-Klipper.git
docker build -t seanauff/octoprint-klipper OctoPrint-Klipper
```
If you already have an image built and are trying to upgrade, you may need to force the build not to use cache:
```shell
docker build -t seanauff/octoprint-klipper --no-cache -pull OctoPrint-Klipper
```
[Octoprint]: https://github.com/foosel/OctoPrint
[Klipper]: https://github.com/KevinOConnor/klipper
[Kiauh]: https://github.com/th33xitus/kiauh
This repository contain the code required to run klipper and octoprint in a docker container, made specifically for Satit Chula's Ender 3 S1 Print Farm

View File

@ -0,0 +1,14 @@
; move head out of the way
G91
G0 Z10
G28 X Y
G0 X0Y230
; disable motors
M84
;disable all heaters
{% snippet 'disable_hotends' %}
{% snippet 'disable_bed' %}
;disable fan
M106 S0

View File

@ -0,0 +1,3 @@
OctoKlipper
config dir: /home/octoprint/.octoprint
log: /home/octoprint/.octoprint/logs/serial.log

216
printer.cfg Normal file
View File

@ -0,0 +1,216 @@
# Ender 3 S1 Config, Satit Chula Specific
[stepper_x]
step_pin: PC2
dir_pin: PB9
enable_pin: !PC3
microsteps: 16
rotation_distance: 40
endstop_pin: !PA5
position_endstop: 0
position_max: 258
homing_speed: 50
[stepper_y]
step_pin: PB8
dir_pin: PB7
enable_pin: !PC3
microsteps: 16
rotation_distance: 40
endstop_pin: !PA6
position_endstop: 0
position_max: 230
homing_speed: 50
[stepper_z]
step_pin: PB6
dir_pin: !PB5
enable_pin: !PC3
microsteps: 16
rotation_distance: 8
endstop_pin: probe:z_virtual_endstop
position_max: 270
position_min: -1
[extruder]
max_extrude_only_distance: 100.0
step_pin: PB4
dir_pin: PB3
enable_pin: !PC3
microsteps: 16
rotation_distance: 7.6190
nozzle_diameter: 0.400
filament_diameter: 1.750
heater_pin: PA1
sensor_type: EPCOS 100K B57560G104F
sensor_pin: PC5
control: pid
pid_Kp: 22.865
pid_Ki: 1.292
pid_Kd: 101.178
min_temp: 0
max_temp: 265
pressure_advance = 0.045
[input_shaper]
shaper_freq_x: 40
shaper_freq_y: 40
[filament_switch_sensor RunoutSensor]
pause_on_runout: False
runout_gcode: PAUSE
insert_gcode: RESUME
switch_pin: !PC15
[heater_bed]
heater_pin: PA7
sensor_type: EPCOS 100K B57560G104F
sensor_pin: PC4
control: pid
pid_Kp: 69.139
pid_Ki: 1.273
pid_Kd: 938.565
min_temp: 0
max_temp: 130
[respond]
default_type: echo
[endstop_phase stepper_x]
[endstop_phase stepper_y]
[gcode_arcs]
resolution: 1.0
[heater_fan hotend_fan]
pin: PC0
heater: extruder
heater_temp: 50.0
[fan]
pin: PA0
[mcu]
serial: /dev/ttyEnder
restart_method: command
[printer]
kinematics: cartesian
max_velocity: 500
max_accel: 3000
max_accel_to_decel: 3000
max_z_velocity: 5
square_corner_velocity: 5.0
max_z_accel: 100
[bltouch]
sensor_pin: ^PC14
control_pin: PC13
x_offset: -32
y_offset: -41
z_offset: 0
speed:10
samples:1
samples_result:average
probe_with_touch_mode: true
stow_on_each_sample: false
[safe_z_home]
home_xy_position: 154,154
speed: 100
z_hop: 10
z_hop_speed: 5
[bed_mesh]
speed: 100
mesh_min: 10, 10
mesh_max: 225, 189
algorithm: bicubic
probe_count: 5,5
[palette2]
serial: /dev/ttyPalette
baud: 115200
feedrate_splice: 0.5
feedrate_normal: 1.0
auto_load_speed: 2
auto_cancel_variation: 0.1
[virtual_sdcard]
path: /home/octoprint/.octoprint/uploads
[display_status]
[pause_resume]
[gcode_macro G29]
description: Mesh Bed Leveling
gcode:
G28
BED_MESH_CALIBRATE
G0 X0Y0Z5
[gcode_macro PAUSE]
description: Pause the actual running print
rename_existing: PAUSE_BASE
# change this if you need more or less extrusion
variable_extrude: 1.0
gcode:
##### read E from pause macro #####
{% set E = printer["gcode_macro PAUSE"].extrude|float %}
##### set park positon for x and y #####
# default is your max posion from your printer.cfg
{% set x_park = printer.toolhead.axis_maximum.x|float - 5.0 %}
{% set y_park = printer.toolhead.axis_maximum.y|float - 5.0 %}
##### calculate save lift position #####
{% set max_z = printer.toolhead.axis_maximum.z|float %}
{% set act_z = printer.toolhead.position.z|float %}
{% if act_z < (max_z - 2.0) %}
{% set z_safe = 2.0 %}
{% else %}
{% set z_safe = max_z - act_z %}
{% endif %}
##### end of definitions #####
PAUSE_BASE
G91
{% if printer.extruder.can_extrude|lower == 'true' %}
G1 E-{E} F2100
{% else %}
{action_respond_info("Extruder not hot enough")}
{% endif %}
{% if "xyz" in printer.toolhead.homed_axes %}
G1 Z{z_safe} F900
G90
G1 X{x_park} Y{y_park} F6000
{% else %}
{action_respond_info("Printer not homed")}
{% endif %}
[gcode_macro RESUME]
description: Resume the actual running print
rename_existing: RESUME_BASE
gcode:
##### read E from pause macro #####
{% set E = printer["gcode_macro PAUSE"].extrude|float %}
#### get VELOCITY parameter if specified ####
{% if 'VELOCITY' in params|upper %}
{% set get_params = ('VELOCITY=' + params.VELOCITY) %}
{%else %}
{% set get_params = "" %}
{% endif %}
##### end of definitions #####
{% if printer.extruder.can_extrude|lower == 'true' %}
G91
G1 E{E} F2100
{% else %}
{action_respond_info("Extruder not hot enough")}
{% endif %}
RESUME_BASE {get_params}
[gcode_macro CANCEL_PRINT]
description: Cancel the actual running print
rename_existing: CANCEL_PRINT_BASE
gcode:
TURN_OFF_HEATERS
CANCEL_PRINT_BASE

View File

@ -5,37 +5,11 @@ import time
import os
import pwd
MJPG = [
"/usr/local/bin/mjpg_streamer",
"-i",
"%(input)s",
"-o",
"output_http.so -p %(port)s -w /usr/local/share/mjpg-streamer/www/",
]
MJPG_INPUT_DEFAULT = "input_uvc.so -r HD"
OCTOPRINT = ["/opt/octoprint/venv/bin/octoprint", "serve"]
OCTOPRINT = ["/opt/octoprint/venv/bin/octoprint", "serve","--port","80"]
def main():
mjpg_processes = []
mjpg_ports = [5000] # Reserve the OctoPrint port
for k, v in os.environ.iteritems():
if k.startswith("MJPG") and not k.startswith("MJPG_"):
v = v.strip()
port_env = "MJPG_PORT" + k[4:]
port = int(os.environ.get(port_env, 8080))
if port in mjpg_ports:
raise ValueError("Port %s from key %s already in use" % (port, port_env))
if not v:
v = MJPG_INPUT_DEFAULT
subs = {'input': v, 'port': port}
cmd = []
for part in MJPG:
cmd.append(part % subs)
print("Starting: %s" % (cmd,))
mjpg_processes.append(subprocess.Popen(cmd))
# Start klipper
klipper = subprocess.Popen(['sudo', '-u', 'octoprint', '/runklipper.py'])

6
start.sh Normal file
View File

@ -0,0 +1,6 @@
#Copy over Initial Printer Config
cp -n /printer.cfg /home/octoprint/.octoprint/printer.cfg
chmod 777 -v /home/octoprint/.octoprint/printer.cfg
#Start OctoPrint and Klipper
python3 /start.py

18
unitconfig.json Normal file
View File

@ -0,0 +1,18 @@
{
"listeners": {
"*:80": {
"pass": "routes"
}
},
"routes": [
{
"match": {
"uri": "*"
},
"action": {
"proxy": "http://127.0.0.1:5000"
}
}
]
}