-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rework Updating #65
Rework Updating #65
Conversation
Wouldn't it make sense to automatically execute |
You are right. This PR is WIP and i want to implement this pseudo code of @pierreozoux:
|
10.0/apache/docker-entrypoint.sh
Outdated
@@ -18,7 +18,18 @@ if version_greater "$installed_version" "$image_version"; then | |||
fi | |||
|
|||
if version_greater "$image_version" "$installed_version"; then | |||
tar cf - --one-file-system -C /usr/src/nextcloud . | tar xf - | |||
rsync -a --delete --exclude /config/ --exclude /data/ --exclude /apps/ /usr/src/nextcloud/ /var/www/html/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any reason why the tarball isn't directly extracted to /var/www/html in the Dockerfile? Then you wouldn't need to copy here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes because we need to use a volume to mount it into nginx. And a container on its own will not overwrite the content of a volume.
docker-entrypoint.sh
Outdated
if version_greater "$installed_version" "$image_version"; then | ||
echo "Downgrade not supported" | ||
exit 1 | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check will break the update app. This mean if we keep it we should disable the update app.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me \o/ Thanks for the work.
Looks like the app folder is already splitted?
Agree with the updater, then it is good if we have a consistent way.
10.0/apache/apps.config.php
Outdated
"writable" => false, | ||
), | ||
1 => array ( | ||
"path" => OC::$SERVERROOT."/apps2", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about having a better naming than 2
?
What about custom_apps
or user_apps
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aside from my comments this looks okay at the moment -- though we should disable the update app (as you said) and write some documentation to explain how this has to be used.
I recently figured out that my current NextCloud setup is broken because of this issue so I'll be reinstalling soon and I'll be able to tell you how well this new system works.
Also it'd be nice if you squashed some of your commits (the app2
and custom_app
commits for example).
Though, can you explain what you mean in the issue description by "replace chown -R www-data
"?
docker-entrypoint.sh
Outdated
[[ "$(printf '%s\n' "$@" | sort -V | head -n 1)" != "$1" ]]; | ||
} | ||
|
||
installed_version="0.0.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor nit, it would be nice if we made this 0.0.0~unknown
or something like that. But it's not necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this could cause problems inside the version_greater
function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No it won't -- I work with rpm-style versions quite a lot. sort -V
does version checks against the leading digits first. In general you would use ~
for things like 1.0.0~rc1
which is a lower version number than 1.0.0
(or 1.0.0~rc2
). However something like 0.0.0+rc1
is a higher version number than 1.0.0
.
But it's up to you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for explaining, i changed it.
docker-entrypoint.sh
Outdated
fi | ||
|
||
if version_greater "$image_version" "$installed_version"; then | ||
if version_greater "$installed_version" "0.0.0"; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should do something like [[ "$installed_version" != "0.0.0" ]]
in all of these cases to make it more clear which is the upgrade path and which is the fresh install path?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
I want to fix #26. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work so far!
I've one question regarding the volume declaration:
With your function to compare the versions we know what kind of installation we're dealing with (new one, existing one, upgrade, downgrade). Since you also split the app folder, is there any reason to have a volume for the /var/www/html
folder?
The Dockerfile could just install the newest version directly to /var/www/html
. The entrypoint script checks the possibilities (new installation does not contain a config.php
):
- no
config.php
: create new one with default content (e.g. split app folder) - existing
config.php
with matching version: do nothing - existing
config.php
with higher version: exit 1 and echo error - existing
config.php
with lower version: perfom occ:upgrade
This would save us a lot of scripting and the whole chown
deal.
10.0/apache/docker-entrypoint.sh
Outdated
image_version=$(php -r 'require "/usr/src/nextcloud/version.php"; echo "$OC_VersionString";') | ||
|
||
if version_greater "$installed_version" "$image_version"; then | ||
echo "Downgrade not supported" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should probably be more specific. Something like
echo "Can't start Nextcloud because the version of the data ($installed_version) is higher than the docker image version ($image_version) and downgrading is not supported. Are you sure you have pulled the newest image version?"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Hi Guys, If I pull version 11.0.2-fpm, or fpm, or latest, then I would reasonably expect to find that source-code in the source directory. I suggest this:
|
@ChessSpider |
@tilosp When you do a docker --pull to update a container it should reuse the VOLUMEs of the previous version of the container, right? I'm assuming here honestly, as I always declare my volumes explicitly in the docker-compose.. You don't want to recreate the volumes containing dynamic/user data. when updating. As that means you'd lose all the uploaded files/apps/etc? |
@ChessSpider Yes but a newly created container will not overwrite files in a volume it will just add new ones. |
What I propose is something in the direction of:
wait, what, why are the static files all over the place? Are they not collected somewhere in one directory ?
|
just to clarify, the simplified docker-compose for my nginx and app of a project of mine is this:
The app on first-run collects all static files and puts them in the /static/ directory. |
@ChessSpider $ sudo docker run --rm -v test:/usr/src/nextcloud nextcloud:9 bash -c exit
$ sudo docker run --rm -v test:/usr/src/nextcloud nextcloud:10 bash -c exit
$ sudo docker run --rm -v test:/test debian cat /test/version.php
<?php
$OC_Version = array(9,0,57,2);
$OC_VersionString = '9.0.57'; Your static files volumes would have the same problem. |
Yeah but that's with the old VOLUME declaration on /var/www/html right? So that makes sense. The updater only runs if you first remove version.php to start the extraction process. I agree that static files volume would have that behavior, but it would only be a problem while downgrading. Which we don't support anyway. When upgrading, old static files will be overwritten. Deleted static files will not be referenced in the HTML and thus should not be a problem. Also static files should only have to be a VOLUME for the FPM-usecase. I do worry about the static files being scattered across various folders. That does make it a lot less clear which folders should be a VOLUME and which ones should not. There's really no need at all to mount folders with php files in the nginx docker container when using fpm. ==
because when upgrading with this dockerfile, it will not overwrite the contents of /var/www/html/css into the volume? |
@ChessSpider no the Dockerfile places the source-code directly into `/usr/src/nextcloud'. A container will not overwrite the files in a volume when started, this is the reason why we copy them into the volume in the entry-point script. |
@tilosp yeah, but that's why #23 and others are suggesting to remove the volume on /var/www/html right? |
@ChessSpider i'am saying if we use volumes with a smaller scope, we would still have to update the content of the small scope volumes. And this would then again require us to copy the files into the volume. I'am perfectly fine with removing the volume declaration completely and let the user decide which scope they want to use. |
@tilosp Right, we're finally aligned :). You're correct about the static files. I think the VOLUME on /var/www/html needs to be removed either way. You want users to upgrade using PULL instead of using the nextcloud updater, and you want users to get the correct version when using the docker updater. A different solution has to be figured out for the fpm use-case though. Maybe some kind of asset management is possible? Previously I'd say to re-run the asset pipelining feature, and put the VOLUME on the assets/ folder. But that's gone. Do you have a suggestion? Is there a feasible way to concentrate static files in one directory, or is there a limited number of directories which contain static files? Alternatively, we can provide clear instructions which previous volumes has to be removed and recreated in case you want to use it in a php-fpm setup. The neighbors at Wonderfall unfortunately don't have this problem as they run php-fpm alongside nginx inside the container https://github.com/Wonderfall/dockerfiles/blob/master/nextcloud/11.0/Dockerfile |
10.0/apache/docker-entrypoint.sh
Outdated
tar cf - --one-file-system -C /usr/src/nextcloud . | tar xf - | ||
# version_greater A B returns whether A > B | ||
function version_greater() { | ||
[[ "$(printf '%s\n' "$@" | sort -V | head -n 1)" != "$1" ]]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just tried this on an alpine box, and the busybox sort is complaining about the -V
...
I ended up using this:
https://github.com/pierreozoux/docker-alpine/blob/03573c088fc71bc9bd6a6e0b4af262935289621c/builder/scripts/apk-install#L4-L6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that's because sort -V
is a GNU coreutils thing. I really am not a fan of that script you linked, GNU's version checking is much more sophisticated. Are we basing our images on alpine
? I feel like we shouldn't because of the other issues that Alpine container images have...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, we can install coreutils in alpine too.
https://wiki.alpinelinux.org/wiki/How_to_get_regular_stuff_working
What are the other issues?
I really like alpine, and as free software advocates, I believe it is our mission to make this IT world a better place. Alpine is a lot more ecological, that's it.
@ChessSpider @tilosp Removing From my experience, splitting up the |
@cyphar A user can always create a volume on startup with The MySQL Dockerfile you reference only put a VOLUME on the |
should be ready for merge |
@pierreozoux @cyphar can we get this merged before 11.0.3 is released? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks generally OK to me, although I'd feel better if @yosifkit took a look as well. My only question after the look I did was whether there are any technical reasons downgrading isn't supported ATM? (not thinking anything here should change, more curious whether there's some indicator that could possibly be used in the future for determining data compatibility when doing upgrades/downgrades so that this could potentially be expanded 👍) |
Seems fine to me! Seems like we should be able to do something similar in the WordPress image. 😍 |
I think this would be something for the guys working on the server as this is not docker specific 😉 |
/me will test this out soon once I figure out how much of my current data might be FUBAR. |
- `docker`: experimental multiarch (docker-library/docker#52) - `golang`: experimental multiarch (docker-library/golang#158) - `nextcloud`: 10.0.5, 11.0.3, 9.0.58, update via container updates (nextcloud/docker#65) - `postgres`: ensure `postgres` user's HOME has decent permissions (docker-library/postgres#277) - `python`: fix `pip` install to also install `setuptools` and `wheel` (docker-library/python#186, docker-library/python#187)
TODO:
version comparison
occ upgrade
show disabled apps
split the app folder
disable the updater
replace
chown -R www-data /var/www/html
For big installations, chown of data folder is taking a looong time #26