diff --git a/CHANGELOG.md b/CHANGELOG.md index 120bc4a..ae744de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,9 +7,15 @@ ### Breaking changes -PR #135 introduced a change that will not affect most users, but may be a breaking change for existing users that are using a volume mounting strategy other than the recommended strategy. Details follow: +PR #135 introduced a change that will not affect most users, but may be a breaking change for existing users that are using a volume mounting strategy other than the recommended strategy. -- `/octoprint/octoprint` and `/octoprint/plugins` folders are now explicitly created during docker build +We have introduced an optional environment variable you can set to attempt to automigrate the file structures, but this feature was impossible to test for all condidtions, and as such is +defaulted to `false`. We highly recommend you use the OctoPrint backup feature, or use this [docker based method of backing up your container volume][container-backup] before attempting auto-migration. +To attempt auto-migration, set a container environment variable of `AUTOMIGRATE=true`. + +Details of breaking changes follow: + +- `/octoprint/octoprint` and `/octoprint/plugins` folders are now explicitly created during docker build - octoprint service basedir is now `/octoprint/octoprint` (was previously `/octoprint`) - the recommended mount path for the `config-editor` container to has been changed to `octoprint:/octoprint`. See updated examples and usage info in `docker-compose.yml` and `README`. @@ -93,6 +99,8 @@ This new method will allow savvy users to create distinct volumes for plugin bin octoprint configuration data, giving them more ability to selectively control how state and memory consumption are utilized in their octoprint image usage/distribution strategies. +[container-backup]: https://docs.docker.com/storage/volumes/#backup-a-container + ## 2.0.0 ### BREAKING CHANGES diff --git a/Dockerfile b/Dockerfile index 8b7e293..e321f2f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -75,6 +75,7 @@ ENV CAMERA_DEV /dev/video0 ENV MJPG_STREAMER_INPUT -y -n -r 640x480 ENV PIP_USER true ENV PYTHONUSERBASE /octoprint/plugins +ENV PATH "${PYTHONUSERBASE}/bin:${PATH}" # set WORKDIR WORKDIR /octoprint diff --git a/README.md b/README.md index e64f5a6..8c1f74f 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,18 @@ This is the primary image of `octoprint/octoprint`. It is designed to work similarly, and support the same out of the box features as the octopi raspberry-pi machine image, using docker. +The `octoprint/octoprint` image uses semantic versioning, but the tags for `octoprint/octoprint` follow the +version of octoprint contained in the image. As a result we recommend you always check the [CHANGELOG](CHANGELOG.md) +or [Releases](https://github.com/OctoPrint/octoprint-docker/releases) before pulling an image, _even if you are pulling the same tag_. + +You can subscribe to be notified of releases as well, by selecting the Watch button in the upper right corner, +choosing "Custom", and checking "Releases". + +In addition, we know that OctoPrint is not the best suited type of application for containerization, but we're +working hard to make it as compatible as possible. Please check out our [Roadmap](https://github.com/OctoPrint/octoprint-docker/projects/4), +or join the discussion in the `#dev-docker` or `#support-docker` channels on the official OctoPrint Discord +[discord.octoprint.org](https://discord.octoprint.org). + **Tags** - `latest` - will always follow the latest _stable_ release @@ -57,11 +69,12 @@ There are configuration values that you pass using container `--environment` opt Listed below are the options and their defaults. These are implicit in example [docker-compose.yml](docker-compose.yml), and if you wish to change them, refer to the docker-compose docs on setting environment variables. -| variable | default | -| -------- | ------- | -| `CAMERA_DEV` | `/dev/video0` (see [note](#devices_note)) | -| `MJPG_STREAMER_INPUT` | `-y -n -r 640x480` | -| `ENABLE_MJPG_STREAMER` | `false` | +| variable | default | description | +| -------- | ------- | ----------- | +| `CAMERA_DEV` | `/dev/video0` | (see [note](#devices_note)) | +| `MJPG_STREAMER_INPUT` | `-y -n -r 640x480` | params for mjpg-streamer | +| `ENABLE_MJPG_STREAMER` | `false` | enable or disable mjpg-streamer +| `AUTOMIGRATE` | `false` | Will attempt to detect and migrate filesystems structures from previous versions of this image to be compatible with the latest release version. recommend you backup before trying this as this is a new feature that has been difficult to test fully | **note:** You will still need to declare the `device` mapping in your docker-compose file or docker command, even if you explicitly declare the `CAMERA_DEV`. The value of `CAMERA_DEV` is used in starting the mjpg-streamer diff --git a/root/etc/cont-init.d/v3-dir-structure-check b/root/etc/cont-init.d/v3-dir-structure-check new file mode 100644 index 0000000..3795154 --- /dev/null +++ b/root/etc/cont-init.d/v3-dir-structure-check @@ -0,0 +1,38 @@ +#!/usr/bin/with-contenv bash + +: "${AUTOMIGRATE:=false}" + +if $AUTOMIGRATE; then + echo "AUTOMIGATE enabled...." + if [[ -d "/octoprint/data" ]] || [[ -f "/octoprint/config.yaml" ]]; then + echo "octoprint-docker v2 directory structure detected...." + echo "migrating to octoprint-docker v3 directory structure..." + mkdir -p /octoprint/octoprint /octoprint/plugins + mv /octoprint/* /octoprint/octoprint + + [[ -d "/octoprint/octoprint/plugins/bin" ]] && mv /octoprint/octoprint/plugins/bin $PYTHONUSERBASE + [[ -d "/octoprint/octoprint/plugins/lib" ]] && mv /octoprint/octoprint/plugins/lib $PYTHONUSERBASE + [[ -d "/octoprint/octoprint/plugins/include" ]] && mv /octoprint/octoprint/plugins/include $PYTHONUSERBASE + [[ -d "/octoprint/octoprint/plugins/local" ]] && mv /octoprint/octoprint/plugins/local $PYTHONUSERBASE + [[ -d "/octoprint/octoprint/plugins/share" ]] && mv /octoprint/octoprint/plugins/share $PYTHONUSERBASE + + echo "v2 -> v3 octoprint-docker auto-migration migration complete!" + fi + + if [[ -d "/root/.octoprint" ]]; then + echo "octoprint-docker v1 directory structure detected...." + echo "migrating to octoprint-docker v3 directory structure..." + + mkdir -p /octoprint/octoprint /octoprint/plugins + mv /root/.octoprint/* /octoprint/octoprint + + [[ -d "/octoprint/octoprint/plugins/bin" ]] && mv /octoprint/octoprint/plugins/bin $PYTHONUSERBASE + [[ -d "/octoprint/octoprint/plugins/lib" ]] && mv /octoprint/octoprint/plugins/lib $PYTHONUSERBASE + [[ -d "/octoprint/octoprint/plugins/include" ]] && mv /octoprint/octoprint/plugins/include $PYTHONUSERBASE + [[ -d "/octoprint/octoprint/plugins/local" ]] && mv /octoprint/octoprint/plugins/local $PYTHONUSERBASE + [[ -d "/octoprint/octoprint/plugins/share" ]] && mv /octoprint/octoprint/plugins/share $PYTHONUSERBASE + + echo "v1 -> v3 octoprint-docker auto-migration complete!" + fi + +fi diff --git a/test/compose.test.yml b/test/compose.test.yml index e6ca827..c72aa44 100644 --- a/test/compose.test.yml +++ b/test/compose.test.yml @@ -5,12 +5,14 @@ services: build: context: ../ args: - octoprint_ref: 1.5.1 + octoprint_ref: 1.5.2 image: octoprint/octoprint:test ports: - 53333:80 volumes: - octoprint:/octoprint + environment: + - AUTOMIGRATE=true config-editor: image: linuxserver/code-server