Combining Octoprint and other Services

I was running Octoprint from an RPi as a way of managing my 3D printer and accessing it wirelessly.

This worked well, however I was concerned with the hardware limitations of the RPi.

I also wanted to host 3 MJPG webcam streams form the same host and therefore needed to consider a migration to more powerful hardware.

I decided to revive an old NUC style i3 PC.

I went with Debian 20.04 as base OS and decided to utilise docker-compose for an easy way to revert my setup to known good configuration.

So far my docker compose looks like this:

volumes:
  octoprint:
  homer:
  db_data:
  wp_data:

services:
  octoprint_reprap:
    restart: unless-stopped
    image: octoprint/octoprint
    ports:
      - 4000:5000
    devices:
     - '/dev:/dev'
#     - /dev/ttyUSB0:/dev/ttyACM0
    volumes:
     - "octoprint:/octoprint"
     - "/run/udev:/run/udev:ro"
    privileged: true


  ustreamer_USB_Webcam:
    restart: unless-stopped
    image: badsmoke/ustreamer:latest
    ports:
      - 8081:8080
    devices:
      - "/dev/cams/cam1"
    entrypoint: [ "./ustreamer", "--device=/dev/cams/cam1", "--host=0.0.0.0", "--slowdown", "--format=JPEG", "--encoder=HW", "--resolution=640x480", "--desired-fps=30", "--drop-same-frames=30"]

  ustreamer_USB_Endoscope:
    restart: unless-stopped
    image: badsmoke/ustreamer:latest
    ports:
      - 8082:8080
    devices:
      - "/dev/cams/cam2"
    entrypoint: [ "./ustreamer", "--device=/dev/cams/cam2", "--host=0.0.0.0", "--slowdown", "--format=JPEG", "--resolution=640x480", "--desired-fps=30", "--drop-same-frames=30"]

  ustreamer_Birdcam:
    restart: unless-stopped
    image: badsmoke/ustreamer:latest
    ports:
      - 8083:8080
    devices:
      - "/dev/cams/cam3"
    entrypoint: [ "./ustreamer", "--device=/dev/cams/cam3", "--host=0.0.0.0", "--slowdown", "--format=JPEG", "--resolution=1920x1080", "--desired-fps=15", "--drop-same-frames=30"]



    
#  ffmpeg:
#    image: jrottenberg/ffmpeg
#    command: ["-i", "http://192.168.8.36:8083/stream", "-c:v", "libx264", "-preset", "ultrafast", "-tune", "zerolatency", "-c:a", "copy", "-f", "mpegts", "udp://192.168.8.36:1234"]
#     ports:
#      - 1234:1234

  homer:
    restart: unless-stopped
    image: b4bz/homer
    container_name: homer
    volumes:
      - homer:/www/assets
    ports:
      - 80:8080
      - 8080:8080
    user: 1000:1000 # default
    environment:
      - INIT_ASSETS=1 # default

  filebrowser:
    restart: unless-stopped
    image: hurlenko/filebrowser
    ports:
      - 8090:8080
    volumes:
      - /:/data
      - /CONFIG_DIR:/config
    environment:
      - FB_BASEURL=/filebrowser
    restart: always


  db:
    image: mariadb:10.6.4-focal
    #to use MySQL, uncomment the following line
    #image: mysql:8.0.27
    command: '--default-authentication-plugin=mysql_native_password'
    volumes:
      - db_data:/var/lib/mysql
    restart: always
    environment:
      - MYSQL_ROOT_PASSWORD=***********
      - MYSQL_DATABASE=wordpress
      - MYSQL_USER=******
      - MYSQL_PASSWORD=*******
    expose:
      - 3306
      - 33060
  wordpress:
    image: wordpress:latest
    volumes:
      - wp_data:/var/www/html
    ports:
      - 85:80
    restart: always
    environment:
      - WORDPRESS_DB_HOST=db
      - WORDPRESS_DB_USER=*****
      - WORDPRESS_DB_PASSWORD=********
      - WORDPRESS_DB_NAME=wordpress
      

In order to rebuild the docker containers after any changed to the file, I run:

docker-compose -f /octoprint/docker-compose.yml up -d --remove-orphans

The –remove-orphans tag ensures any containers no longer mentioned in the compose file are taken down.

Work to do: Implement a method of triggering this command via HTTP request fo fast rebuild via Homer