132 lines
5.4 KiB
Markdown
132 lines
5.4 KiB
Markdown
OctoPrint containers
|
|
====================
|
|
|
|
# Contents
|
|
<!-- TOC START min:1 max:3 link:true update:false -->
|
|
- [Introduction](#introduction)
|
|
- [Docker setup](#docker-setup)
|
|
- [Prepare the Raspberry Pi](#prepare-the-raspberry-pi)
|
|
- [Get the containers](#get-the-containers)
|
|
- [Option 1: Download the containers](#option-1-download-the-containers)
|
|
- [Option 2: Re-Build the containers](#option-2-re-build-the-containers)
|
|
- [Configure and run the OctoPrint server](#configure-and-run-the-octoprint-server)
|
|
- [Updates](#updates)
|
|
- [First run](#first-run)
|
|
- [Note about persistence](#note-about-persistence)
|
|
|
|
<!-- TOC END -->
|
|
# Introduction
|
|
This is a Docker setup for [OctoPrint](https://octoprint.org/) on Raspberry Pi.
|
|
|
|
The setup is made of 3 containers:
|
|
- `octoprint`: runs the main [OctoPrint](https://octoprint.org/) application
|
|
- `klipper`: runs the [klipper](https://github.com/KevinOConnor/klipper) application
|
|
- `webcam`: runs the webcam streaming service (`mjpg-streamer`)
|
|
- `haproxy`: exposes the above containers on http and https ports
|
|
|
|
The build will use by default the latest [OctoPrint](https://octoprint.org/) release, this can be overridden by changing the `release` argument in the `docker-compose.yml` file.
|
|
|
|
This setup will run on any Raspberry Pi, however [OctoPrint](https://octoprint.org/) recommends a Raspberry Pi 3 or 3+.
|
|
|
|
## Configure your OctoPrint device
|
|
The Environment Variables menu "E(x)" allows you to add variables to configure the device for your usage.
|
|
|
|
You can add the following variables:
|
|
|
|
Name | Default | Description
|
|
-------------|----------------------------|------------
|
|
WEBCAM_START | `true` | Start the webcam streaming at boot time.<br>Use false if you have no webcam or want to start it from the [OctoPrint](https://octoprint.org/) menu
|
|
WEBCAM_INPUT | `input_raspicam.so -fps 5` | The input plugin for [`mjpg-streamer`](https://github.com/jacksonliam/mjpg-streamer).<br>Default is for the Raspberry Pi camera, see the documentation for others.<br>Example for an USB webcam: `input_uvc.so -d /dev/video0 -r 640x480 -fps 5`.
|
|
|
|
# Docker setup
|
|
|
|
## Prepare the Raspberry Pi
|
|
Download and install [Raspbian Stretch Lite](https://www.raspberrypi.org/downloads/raspbian/) to your Pi (Follow the instructions from the Foundation).
|
|
Although it will work with the full _Desktop_ environment, I strongly recommend the _Lite_ version.
|
|
|
|
As root, install `git`, `docker` and `docker-compose`:
|
|
```
|
|
# apt-get update
|
|
# apt-get install git curl python-pip
|
|
# curl -sSL https://get.docker.com | sh
|
|
# pip install docker-compose
|
|
```
|
|
Ensure your linux user (`pi` or whatever you choose) is in the `docker` group:
|
|
```
|
|
# usermod -a -G docker <YourLinuxUser>
|
|
```
|
|
At this point you need to completely logout and re-login to activate the new group.
|
|
|
|
From here, __you don't need root access anymore__.
|
|
|
|
Clone this repository:
|
|
```
|
|
$ git clone https://git.ring-zero.co.uk/docker/octoprint-containers.git
|
|
$ cd octoprint-containers/
|
|
```
|
|
|
|
## Get the containers
|
|
You have 2 options here: download the pre-build containers or re-build them.
|
|
|
|
### Option 1: Download the containers
|
|
This is the easiest and fastest way. The `pull` command will download the containers from the Docker Hub:
|
|
```
|
|
$ docker-compose pull
|
|
```
|
|
__If you are not using a Raspberry Pi 3__: _multiarch_ build does not work properly on ARM variants (See https://github.com/moby/moby/issues/34875 ).
|
|
For older Raspberry Pi you need to amend the _docker-compose_ files to pull the correct images:
|
|
```
|
|
$ sed -e 's/\(image:.*\)/\1:arm32v6-latest/' -i.orig docker-compose.yml
|
|
```
|
|
|
|
### Option 2: Re-Build the containers
|
|
If for whatever reason you want to re-build the containers on your Pi, run:
|
|
```
|
|
$ docker-compose build
|
|
```
|
|
__If you are not using a Raspberry Pi 3__: copy the `.env-distr` to `.env` and select you Raspberry Pi version.
|
|
|
|
## Configure and run the OctoPrint server
|
|
If you don't do that, you won't be able to restart or shut down you Pi from the [OctoPrint](https://octoprint.org/) user interface.
|
|
|
|
Run the [OctoPrint](https://octoprint.org/) server:
|
|
```
|
|
$ docker-compose up
|
|
```
|
|
This will start the containers and remain attached to your terminal. If everything looks good, you can cancel it and restart the service in detached mode:
|
|
```
|
|
$ docker-compose up -d
|
|
```
|
|
This will keep he containers running, even after a reboot.
|
|
|
|
## Updates
|
|
To update your setup with a newer version, get the latest code and containers and restart the service:
|
|
```
|
|
$ docker-compose down
|
|
$ git pull origin master
|
|
$ docker-compose pull # or build
|
|
$ docker-compose up -d
|
|
```
|
|
|
|
# First run
|
|
|
|
Point your browser to the IP address of your Raspberry Pi and enjoy [OctoPrint](https://octoprint.org/)!
|
|
|
|
At first run, the `haproxy` container will generate a self-signed SSL certificate, so the service will be available on both http and https ports. If you want to share your printer with the world, only expose the https port...
|
|
|
|
Enjoy!
|
|
|
|
# Note about persistence
|
|
All working files (configuration, G-Code, time-lapses, ...) are stored in the `octoprint_vol` Docker volume, so they won't disappear unless you explicitly destroy the volume.
|
|
```
|
|
docker-compose down -v
|
|
```
|
|
|
|
The same applies to the containers themselves: they won't be destroyed by default even if you reboot the Pi. To remove existing container and re-create them:
|
|
```
|
|
docker-compose down
|
|
docker-compose up -d
|
|
```
|
|
|
|
By doing this, you will loose any change made to the code, in particular if you installed plugins you will have to re-install them (but their configuration will be preserved).
|