Skip to content

Commit

Permalink
Merge pull request #142 from OctoPrint/v3-image-migration
Browse files Browse the repository at this point in the history
V3 image migration
  • Loading branch information
LongLiveCHIEF committed Dec 13, 2020
2 parents 20276c3 + 65f6c6f commit d735263
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 8 deletions.
12 changes: 10 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.

Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
23 changes: 18 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
38 changes: 38 additions & 0 deletions root/etc/cont-init.d/v3-dir-structure-check
Original file line number Diff line number Diff line change
@@ -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
4 changes: 3 additions & 1 deletion test/compose.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d735263

Please sign in to comment.