Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ name: Python Lint & Type Check

on:
push:
branches:
- release
pull_request:

jobs:
Expand Down Expand Up @@ -50,4 +52,4 @@ jobs:

# - name: 🐶 Ruff
# run: |
# ruff check
# ruff check
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@
"Klippy",
"levelname",
"levelno",
"libjpeg",
"linkhelper",
"Liveview",
"localauth",
Expand All @@ -144,7 +145,7 @@
"moonrakerapirouter",
"moonrakerclient",
"moonrakercommandhandler",
"moonrakercredentailmanager",
"moonrakercredentialmanager",
"moonrakerdatabase",
"moonrakerhost",
"moonrakerwebcamhelper",
Expand Down
56 changes: 56 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Start with the latest alpine, for a solid base,
# since we need some advance binaries for things like pillow and ffmpeg.
FROM alpine:3.21.3

# Create a non-root user to run, so we don't run as root.
# There's no need to run as root and it helps some platforms like openshift.
RUN adduser -Ss /bin/bash app -h /app -g root -u 1001

WORKDIR /app

# Define some user vars we will use for the image.
# These are read in the docker_octoapp module, so they must not change!
ENV USER=app
ENV REPO_DIR=/app/octoapp
ENV VENV_DIR=/app/octoapp-env
# This is a special dir that the user MUST mount to the host, so that the data is persisted.
# If this is not mounted, the printer will need to be re-linked every time the container is remade.
ENV DATA_DIR=/data/

# Install the required packages.
# Any packages here should be mirrored in the install script - and any optional pillow packages done inline.
# GCC, python3-dev, and musl-dev are required for pillow, and jpeg-dev and zlib-dev are required for jpeg support.
RUN apk add --no-cache curl ffmpeg jq python3 python3-dev gcc musl-dev py3-pip py3-virtualenv jpeg-dev libjpeg-turbo-dev zlib-dev py3-pillow libffi-dev

# Timezone setup steps
# These steps are necessary to add timezone support to the container and allow for setting the timezone
# This allows the log files to show the correct local time
RUN apk add --no-cache tzdata
ENV TZ=Etc/GMT
RUN cp /usr/share/zoneinfo/Etc/GMT /etc/localtime

#
# We decided to not run the installer, since the point of the installer is to setup the env, build the launch args, and setup the service.
# Instead, we will manually run the smaller subset of commands that are required to get the env setup in docker.
# Note that if this ever becomes too much of a hassle, we might want to revert back to using the installer, and supporting a headless install.
#
RUN virtualenv -p /usr/bin/python3 ${VENV_DIR}
RUN ${VENV_DIR}/bin/python -m pip install --upgrade pip

# Copy the entire repo into the image, do this as late as possible to avoid rebuilding the image every time the repo changes.
COPY ./ ${REPO_DIR}/
RUN ${VENV_DIR}/bin/pip3 install --require-virtualenv --no-cache-dir -q -r ${REPO_DIR}/requirements.txt

# Install the optional packages for zstandard compression.
# THIS VERSION STRING MUST STAY IN SYNC with Compression.ZStandardPipPackageString
RUN apk add zstd
RUN ${VENV_DIR}/bin/pip3 install --require-virtualenv --no-cache-dir -q "zstandard>=0.21.0,<0.23.0"

# Ensure directories have correct ownership. Having the group set to root(0) and writable by group will allow this to run on openshift
RUN chown -R 1001:0 /app && chmod -R g+wx /app

# For docker, we use our docker_octoapp host to handle the runtime setup and launch of the service.
WORKDIR ${REPO_DIR}

# Use the full path to the venv, we must use this [] notation for our ctl-c handler to work in the container.
ENTRYPOINT ["/app/octoapp-env/bin/python", "-m", "docker_octoapp"]
5 changes: 3 additions & 2 deletions bambu_octoapp/__main__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import sys
from typing import Optional

from linux_host.startup import Startup
from linux_host.startup import ConfigDataTypes
Expand All @@ -11,10 +12,10 @@
s = Startup()

# Try to parse the config
jsonConfigStr = None
jsonConfigStr:Optional[str] = None
try:
# Get the json from the process args.
jsonConfig = s.GetJsonFromArgs(sys.argv)
(jsonConfigStr, jsonConfig) = s.GetJsonFromArgs(sys.argv)

#
# Parse the common, required args.
Expand Down
8 changes: 6 additions & 2 deletions bambu_octoapp/bambudatabase.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,12 @@ def _DeleteDatabaseFiles(self, names: List[str]):
results = {}
try:
for name in names:
ftp.delete(self._GetDbPath(name))
results[name] = True
try:
ftp.delete(self._GetDbPath(name))
results[name] = True
except Exception as e:
results[name] = False
self.Logger.error(f"Failed to delete {name}", e)
finally:
ftp.quit()

Expand Down
Empty file modified developer/init-env.sh
100644 → 100755
Empty file.
121 changes: 121 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
version: '2'
services:
octoapp-plugin:
image: bmerrill9/octoapp_plugin
environment:
# Required: The mode of OctoApp Companion Plugin you want use.
# - bambu: Bambu Companion Plugin - for Bambu Lab 3D printers such as the Bambu Lab A1, P1, and X1 series.
# - elegoo: Elegoo Companion Plugin - for Elegoo OS 3D printers such as the Elegoo Centauri & Elegoo Centauri Carbon.
# - klipper: Use this for Klipper / Moonraker based printers.
#
# Set this to the mode you want to use, and then uncomment the required settings for the mode bellow.
- COMPANION_MODE=bambu

#
# Required for Bambu Connect
#
# https://octoeverywhere.com/s/access-code
#- ACCESS_CODE=5285c831
#
# https://octoeverywhere.com/s/bambu-sn
#- SERIAL_NUMBER=00M09C411200608
#
# Find using the printer's display or use https://octoeverywhere.com/s/bambu-ip
#- PRINTER_IP=10.0.0.23


#
# Required for Elegoo Connect
#
# Find using the printer's display or use https://octoeverywhere.com/s/elegoo-ip
#- PRINTER_IP=XXX.XXX.XXX.XXX


#
# Required For Klipper / Moonraker
#
# Required - The IP address of the Klipper/Moonraker/Webserver/Printer
#- PRINTER_IP=XXX.XXX.XXX.XXX
#
# Optional - The port of Moonraker. This defaults to 7125 if not set.
#- MOONRAKER_PORT=7125
#
# Optional - If your Moonraker needs API key auth, you can generate it in Mainsail or Fluidd and set it here.
#- MOONRAKER_API_KEY=someApiKey
#
# Optional - The port of frontend webserver. This defaults to 80 if not set.
#- WEBSERVER_PORT=80

#
# Optional Settings For All Modes
#
# Set timezone to proper timezone for logs using standard timezones:
# https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List
- TZ=America/New_York

volumes:
# This can also be an absolute path, e.g. /var/octoapp/plugin/data or /c/users/name/plugin/data
- ./data:/data




#
# Add as many printers and printer types as you want!
#
# octoapp-plugin-2:
# image: bmerrill9/octoapp_plugin
# environment:
# # Required: The mode of OctoApp Companion Plugin you want use.
# # - bambu: Bambu Companion Plugin - for Bambu Lab 3D printers such as the Bambu Lab A1, P1, and X1 series.
# # - elegoo: Elegoo Companion Plugin - for Elegoo OS 3D printers such as the Elegoo Centauri & Elegoo Centauri Carbon.
# # - klipper: Use this for Klipper / Moonraker based printers.
# #
# # Set this to the mode you want to use, and then uncomment the required settings for the mode bellow.
# - COMPANION_MODE=bambu

# #
# # Required for Bambu Connect
# #
# # https://octoeverywhere.com/s/access-code
# #- ACCESS_CODE=5285c831
# #
# # https://octoeverywhere.com/s/bambu-sn
# #- SERIAL_NUMBER=00M09C411200608
# #
# # Find using the printer's display or use https://octoeverywhere.com/s/bambu-ip
# #- PRINTER_IP=10.0.0.23


# #
# # Required for Elegoo Connect
# #
# # Find using the printer's display or use https://octoeverywhere.com/s/elegoo-ip
# #- PRINTER_IP=XXX.XXX.XXX.XXX


# #
# # Required For Klipper / Moonraker
# #
# # Required - The IP address of the Klipper/Moonraker/Webserver/Printer
# #- PRINTER_IP=XXX.XXX.XXX.XXX
# #
# # Optional - The port of Moonraker. This defaults to 7125 if not set.
# #- MOONRAKER_PORT=7125
# #
# # Optional - If your Moonraker needs API key auth, you can generate it in Mainsail or Fluidd and set it here.
# #- MOONRAKER_API_KEY=someApiKey
# #
# # Optional - The port of frontend webserver. This defaults to 80 if not set.
# #- WEBSERVER_PORT=80

# #
# # Optional Settings For All Modes
# #
# # Set timezone to proper timezone for logs using standard timezones:
# # https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List
# - TZ=America/New_York

# volumes:
# # This can also be an absolute path, e.g. /var/octoapp/plugin/data or /c/users/name/plugin/data
# - ./data:/data
99 changes: 99 additions & 0 deletions docker-readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# OctoApp Companion Docker Image

OctoApp's Companion Docker image works with: ✅

- [OctoApp Bambu Companion Plugin](https://github.com/crysxd/OctoApp-Plugin/wiki/Installation-for-BambuLab) - OctoApp for Bambu Lab 3D printers.
- [OctoApp Elegoo Companion Plugin](https://github.com/crysxd/OctoApp-Plugin/wiki/Installation-on-Elegoo-Centauri) - OctoApp for Elegoo Centauri & Centauri Carbon 3D printers.
- [OctoApp Klipper Companion](https://github.com/crysxd/OctoApp-Plugin/wiki/Installation-on-Klipper) - OctoApp for Klipper 3D printers.

OctoApp's Companion Docker image **does not work with:** ⛔

- [OctoApp For OctoPrint](https://github.com/crysxd/OctoApp-Plugin/wiki/Installation-on-OctoPrint) - Install the OctoApp plugin directly in OctoPrint.
- [OctoApp For Klipper](https://github.com/crysxd/OctoApp-Plugin/wiki/Installation-on-Klipper) - If you can install OctoApp on the same device running Klipper, it's the recommended setup. Otherwise use the OctoApp Klipper Companion.


🤔 Confused? [Follow our step-by-step guide](https://github.com/crysxd/OctoApp-Plugin/wiki) to find the right version for your 3D printer!

Docker Image: https://hub.docker.com/r/bmerrill9/octoapp_plugin

Based on this Docker Compose: [GitHub Repo File](https://github.com/QuinnDamerell/OctoPrint-OctoEverywhere/blob/master/docker-compose.yml)

## Required Image Setup Information

There are three modes of the OctoApp docker image depending on what 3D printer you're trying to use.

- `COMPANION_MODE=bambu` - Bambu Companion Plugin for Bambu Lab 3D printer.
- `COMPANION_MODE=elegoo` - Elegoo Companion Plugin for the Elegoo Centauri & Centauri Carbon.
- `COMPANION_MODE=klipper` - For Klipper / Moonraker based 3D printers.

Different companion modes need different printer information.

### Bambu Companion Plugin

To use Bambu Companion Plugin, you need to get the following information.

- Your printer's Access Code - https://octoeverywhere.com/s/access-code
- Your printer's Serial Number - https://octoeverywhere.com/s/bambu-sn
- Your printer's IP Address - https://octoeverywhere.com/s/bambu-ip

These three values must be set as environment vars when you first run the container. Once the container is run, you don't need to include them again, unless you want to update the values.

- ACCESS_CODE=(code)
- SERIAL_NUMBER=(serial number)
- PRINTER_IP=(ip address)

### Elegoo Companion Plugin

To use Elegoo Companion Plugin, you need to get the following information.

- Your Elegoo printer's IP address. - https://octoeverywhere.com/s/elegoo-ip

The IP address must be set as an environment var when you first run the container. Once the container is run, you don't need to include them again, unless you want to update the values.

- PRINTER_IP=(ip address)

### Klipper Companion

To use the Klipper Companion, you need to get the following information.

- Your printer's IP address.
- (optional) Moonraker's server port. Defaults to 7125.
- (optional) Moonraker API key. Defaults to None. If your Moonraker server requires auth, you can generate an API key in Mainsail or Fluidd.
- (optional) Your web frontend's server port. Defaults to 80.

These three values must be set as environment vars when you first run the container. Once the container is run, you don't need to include them again, unless you want to update the values.

- PRINTER_IP=(ip address)
- MOONRAKER_PORT=(port)
- MOONRAKER_API_KEY=(apiKey)
- WEBSERVER_PORT=(port)

## Required Persistent Storage

You must map the `/data` folder in your docker container to a directory on your computer so the plugin can write data that will remain between runs. Failure to do this will require relinking the plugin when the container is destroyed or updated.

# Running The Docker Image

## Building The Image Locally

You can build the docker image locally if you prefer, use the following command.

`docker build -t octoapp .`

## Using Docker Compose

Using docker compose is the easiest way to run the OctoApp Companion Plugin is using docker image.

- Install [Docker and Docker Compose](https://docs.docker.com/compose/install/linux/)
- Clone this repo
- Edit the `./docker-compose.yml` file to enter your environment information.
- Run `docker compose up -d`
- Follow the "Linking Your OctoApp Companion" to link the plugin with your account.

## Using Docker

Docker compose is a fancy wrapper to run docker containers. You can also run docker containers manually.

Use a command like this example, but update the required vars.

`docker run --name octoapp -e COMPANION_MODE=<mode> -e PRINTER_IP=<ip address> (add other required env vars) -v /your/local/path:/data -d octoapp`
Loading