Skip to content

Commit d735263

Browse files
Merge pull request #142 from OctoPrint/v3-image-migration
V3 image migration
2 parents 20276c3 + 65f6c6f commit d735263

File tree

5 files changed

+70
-8
lines changed

5 files changed

+70
-8
lines changed

CHANGELOG.md

+10-2
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,15 @@
77

88
### Breaking changes
99

10-
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:
10+
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.
1111

12-
- `/octoprint/octoprint` and `/octoprint/plugins` folders are now explicitly created during docker build
12+
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
13+
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.
14+
To attempt auto-migration, set a container environment variable of `AUTOMIGRATE=true`.
15+
16+
Details of breaking changes follow:
17+
18+
- `/octoprint/octoprint` and `/octoprint/plugins` folders are now explicitly created during docker build
1319
- octoprint service basedir is now `/octoprint/octoprint` (was previously `/octoprint`)
1420
- 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`.
1521

@@ -93,6 +99,8 @@ This new method will allow savvy users to create distinct volumes for plugin bin
9399
octoprint configuration data, giving them more ability to selectively control how state and
94100
memory consumption are utilized in their octoprint image usage/distribution strategies.
95101

102+
[container-backup]: https://docs.docker.com/storage/volumes/#backup-a-container
103+
96104
## 2.0.0
97105

98106
### BREAKING CHANGES

Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ ENV CAMERA_DEV /dev/video0
7575
ENV MJPG_STREAMER_INPUT -y -n -r 640x480
7676
ENV PIP_USER true
7777
ENV PYTHONUSERBASE /octoprint/plugins
78+
ENV PATH "${PYTHONUSERBASE}/bin:${PATH}"
7879
# set WORKDIR
7980
WORKDIR /octoprint
8081

README.md

+18-5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,18 @@
33
This is the primary image of `octoprint/octoprint`. It is designed to work similarly, and support the
44
same out of the box features as the octopi raspberry-pi machine image, using docker.
55

6+
The `octoprint/octoprint` image uses semantic versioning, but the tags for `octoprint/octoprint` follow the
7+
version of octoprint contained in the image. As a result we recommend you always check the [CHANGELOG](CHANGELOG.md)
8+
or [Releases](https://github.com/OctoPrint/octoprint-docker/releases) before pulling an image, _even if you are pulling the same tag_.
9+
10+
You can subscribe to be notified of releases as well, by selecting the Watch button in the upper right corner,
11+
choosing "Custom", and checking "Releases".
12+
13+
In addition, we know that OctoPrint is not the best suited type of application for containerization, but we're
14+
working hard to make it as compatible as possible. Please check out our [Roadmap](https://github.com/OctoPrint/octoprint-docker/projects/4),
15+
or join the discussion in the `#dev-docker` or `#support-docker` channels on the official OctoPrint Discord
16+
[discord.octoprint.org](https://discord.octoprint.org).
17+
618
**Tags**
719

820
- `latest` - will always follow the latest _stable_ release
@@ -57,11 +69,12 @@ There are configuration values that you pass using container `--environment` opt
5769
Listed below are the options and their defaults. These are implicit in example [docker-compose.yml](docker-compose.yml),
5870
and if you wish to change them, refer to the docker-compose docs on setting environment variables.
5971

60-
| variable | default |
61-
| -------- | ------- |
62-
| `CAMERA_DEV` | `/dev/video0` (see [note](#devices_note)) |
63-
| `MJPG_STREAMER_INPUT` | `-y -n -r 640x480` |
64-
| `ENABLE_MJPG_STREAMER` | `false` |
72+
| variable | default | description |
73+
| -------- | ------- | ----------- |
74+
| `CAMERA_DEV` | `/dev/video0` | (see [note](#devices_note)) |
75+
| `MJPG_STREAMER_INPUT` | `-y -n -r 640x480` | params for mjpg-streamer |
76+
| `ENABLE_MJPG_STREAMER` | `false` | enable or disable mjpg-streamer
77+
| `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 |
6578

6679
**note:** You will still need to declare the `device` mapping in your docker-compose file or docker command,
6780
even if you explicitly declare the `CAMERA_DEV`. The value of `CAMERA_DEV` is used in starting the mjpg-streamer
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/usr/bin/with-contenv bash
2+
3+
: "${AUTOMIGRATE:=false}"
4+
5+
if $AUTOMIGRATE; then
6+
echo "AUTOMIGATE enabled...."
7+
if [[ -d "/octoprint/data" ]] || [[ -f "/octoprint/config.yaml" ]]; then
8+
echo "octoprint-docker v2 directory structure detected...."
9+
echo "migrating to octoprint-docker v3 directory structure..."
10+
mkdir -p /octoprint/octoprint /octoprint/plugins
11+
mv /octoprint/* /octoprint/octoprint
12+
13+
[[ -d "/octoprint/octoprint/plugins/bin" ]] && mv /octoprint/octoprint/plugins/bin $PYTHONUSERBASE
14+
[[ -d "/octoprint/octoprint/plugins/lib" ]] && mv /octoprint/octoprint/plugins/lib $PYTHONUSERBASE
15+
[[ -d "/octoprint/octoprint/plugins/include" ]] && mv /octoprint/octoprint/plugins/include $PYTHONUSERBASE
16+
[[ -d "/octoprint/octoprint/plugins/local" ]] && mv /octoprint/octoprint/plugins/local $PYTHONUSERBASE
17+
[[ -d "/octoprint/octoprint/plugins/share" ]] && mv /octoprint/octoprint/plugins/share $PYTHONUSERBASE
18+
19+
echo "v2 -> v3 octoprint-docker auto-migration migration complete!"
20+
fi
21+
22+
if [[ -d "/root/.octoprint" ]]; then
23+
echo "octoprint-docker v1 directory structure detected...."
24+
echo "migrating to octoprint-docker v3 directory structure..."
25+
26+
mkdir -p /octoprint/octoprint /octoprint/plugins
27+
mv /root/.octoprint/* /octoprint/octoprint
28+
29+
[[ -d "/octoprint/octoprint/plugins/bin" ]] && mv /octoprint/octoprint/plugins/bin $PYTHONUSERBASE
30+
[[ -d "/octoprint/octoprint/plugins/lib" ]] && mv /octoprint/octoprint/plugins/lib $PYTHONUSERBASE
31+
[[ -d "/octoprint/octoprint/plugins/include" ]] && mv /octoprint/octoprint/plugins/include $PYTHONUSERBASE
32+
[[ -d "/octoprint/octoprint/plugins/local" ]] && mv /octoprint/octoprint/plugins/local $PYTHONUSERBASE
33+
[[ -d "/octoprint/octoprint/plugins/share" ]] && mv /octoprint/octoprint/plugins/share $PYTHONUSERBASE
34+
35+
echo "v1 -> v3 octoprint-docker auto-migration complete!"
36+
fi
37+
38+
fi

test/compose.test.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@ services:
55
build:
66
context: ../
77
args:
8-
octoprint_ref: 1.5.1
8+
octoprint_ref: 1.5.2
99
image: octoprint/octoprint:test
1010
ports:
1111
- 53333:80
1212
volumes:
1313
- octoprint:/octoprint
14+
environment:
15+
- AUTOMIGRATE=true
1416

1517
config-editor:
1618
image: linuxserver/code-server

0 commit comments

Comments
 (0)