0
0
Fork 0
mirror of https://github.com/nextcloud/docker.git synced 2025-06-16 16:14:47 +02:00

Removes VOLUME directive.

In a kubernetes env, this is causing a lot of issues.
We want a read only docker image. And this helps.
And as you see it removes a lot of logic that is always a good things to remove lines ;)

The last logic piece that is needed, is to know if the Nc is installed or not, and we can get this from `occ status`.

In term of upgrade Nobody will lost the data.
There is just one thing, for people relying on /var/www/html/ is that the Nextcloud will not update anymore.
But I guess people will realize and search what is happening.
For convenience, we could put a warning in the entrypoint, and detect this case.
What do you think? I know it is tricky to update these things, but I think we agree that we have to get rid of this old logic.

Signed-off-by: pierreozoux <pierre@ozoux.net>
This commit is contained in:
pierreozoux 2020-01-17 15:45:38 +01:00
parent c4ccb67a0d
commit e33f20dc92
6 changed files with 91 additions and 143 deletions

View file

@ -90,7 +90,6 @@ RUN { \
chown -R www-data:root /var/www; \
chmod -R g=u /var/www
VOLUME /var/www/html
%%VARIANT_EXTRAS%%
ENV NEXTCLOUD_VERSION %%VERSION%%
@ -109,17 +108,22 @@ RUN set -ex; \
# gpg key from https://nextcloud.com/nextcloud.asc
gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys 28806A878AE423A28372792ED75899B9A724937A; \
gpg --batch --verify nextcloud.tar.bz2.asc nextcloud.tar.bz2; \
tar -xjf nextcloud.tar.bz2 -C /usr/src/; \
tar -xjf nextcloud.tar.bz2 -C /var/www/; \
rm -rf /var/www/html; \
mv /var/www/nextcloud /var/www/html; \
gpgconf --kill all; \
rm -r "$GNUPGHOME" nextcloud.tar.bz2.asc nextcloud.tar.bz2; \
rm -rf /usr/src/nextcloud/updater; \
mkdir -p /usr/src/nextcloud/data; \
mkdir -p /usr/src/nextcloud/custom_apps; \
chmod +x /usr/src/nextcloud/occ; \
apk del .fetch-deps
rm -r "$GNUPGHOME"; \
rm -rf /var/www/html/updater; \
mkdir -p /var/www/html/data; \
mkdir -p /var/www/html/custom_apps; \
chmod +x /var/www/html/occ; \
apk del .fetch-deps; \
touch /var/www/html/data/.ocdata; \
touch /var/www/html/config/config.php; \
chown -R www-data:root /var/www/html
COPY *.sh upgrade.exclude /
COPY config/* /usr/src/nextcloud/config/
COPY *.sh /
COPY --chown=www-data:root config/* /var/www/html/config/
ENTRYPOINT ["/entrypoint.sh"]
CMD ["%%CMD%%"]

View file

@ -103,7 +103,6 @@ RUN { \
chown -R www-data:root /var/www; \
chmod -R g=u /var/www
VOLUME /var/www/html
%%VARIANT_EXTRAS%%
ENV NEXTCLOUD_VERSION %%VERSION%%
@ -124,19 +123,23 @@ RUN set -ex; \
# gpg key from https://nextcloud.com/nextcloud.asc
gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys 28806A878AE423A28372792ED75899B9A724937A; \
gpg --batch --verify nextcloud.tar.bz2.asc nextcloud.tar.bz2; \
tar -xjf nextcloud.tar.bz2 -C /usr/src/; \
tar -xjf nextcloud.tar.bz2 -C /var/www/; \
rm -rf /var/www/html; \
mv /var/www/nextcloud /var/www/html; \
gpgconf --kill all; \
rm -r "$GNUPGHOME" nextcloud.tar.bz2.asc nextcloud.tar.bz2; \
rm -rf /usr/src/nextcloud/updater; \
mkdir -p /usr/src/nextcloud/data; \
mkdir -p /usr/src/nextcloud/custom_apps; \
chmod +x /usr/src/nextcloud/occ; \
\
rm -r "$GNUPGHOME"; \
rm -rf /var/www/html/updater; \
mkdir -p /var/www/html/data; \
mkdir -p /var/www/html/custom_apps; \
chmod +x /var/www/html/occ; \
touch /var/www/html/data/.ocdata; \
touch /var/www/html/config/config.php; \
chown -R www-data:root /var/www/html; \
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $fetchDeps; \
rm -rf /var/lib/apt/lists/*
COPY *.sh upgrade.exclude /
COPY config/* /usr/src/nextcloud/config/
COPY *.sh /
COPY --chown=www-data:root config/* /var/www/html/config/
ENTRYPOINT ["/entrypoint.sh"]
CMD ["%%CMD%%"]

View file

@ -48,17 +48,9 @@ As the fastCGI-Process is not capable of serving static files (style sheets, ima
By default, this container uses SQLite for data storage but the Nextcloud setup wizard (appears on first run) allows connecting to an existing MySQL/MariaDB or PostgreSQL database. You can also link a database container, e. g. `--link my-mysql:mysql`, and then use `mysql` as the database host on setup. More info is in the docker-compose section.
## Persistent data
The Nextcloud installation and all data beyond what lives in the database (file uploads, etc) are stored in the [unnamed docker volume](https://docs.docker.com/engine/tutorials/dockervolumes/#adding-a-data-volume) volume `/var/www/html`. The docker daemon will store that data within the docker directory `/var/lib/docker/volumes/...`. That means your data is saved even if the container crashes, is stopped or deleted.
By default, there is no persistency, that means your data is not saved.
A named Docker volume or a mounted host directory should be used for upgrades and backups. To achieve this, you need one volume for your database container and one for Nextcloud.
Nextcloud:
- `/var/www/html/` folder where all nextcloud data lives
```console
$ docker run -d \
-v nextcloud:/var/www/html \
nextcloud
```
A named Docker volume or a mounted host directory should be used. To achieve this, first, you need one volume for your database containe.
Database:
- `/var/lib/mysql` MySQL / MariaDB Data
@ -69,21 +61,19 @@ $ docker run -d \
mariadb
```
If you want to get fine grained access to your individual files, you can mount additional volumes for data, config, your theme and custom apps.
Then, you need to configure access to your individual files, you have to mount additional volumes for data, config, your theme (optional) and custom apps.
The `data`, `config` files are stored in respective subfolders inside `/var/www/html/`. The apps are split into core `apps` (which are shipped with Nextcloud and you don't need to take care of) and a `custom_apps` folder. If you use a custom theme it would go into the `themes` subfolder.
Overview of the folders that can be mounted as volumes:
- `/var/www/html` Main folder, needed for updating
- `/var/www/html/custom_apps` installed / modified apps
- `/var/www/html/config` local configuration
- `/var/www/html/data` the actual data of your Nextcloud
- `/var/www/html/themes/<YOUR_CUSTOM_THEME>` theming/branding
- `/var/www/html/themes/<YOUR_CUSTOM_THEME>` theming/branding (optional)
If you want to use named volumes for all of these, it would look like this:
```console
$ docker run -d \
-v nextcloud:/var/www/html \
-v apps:/var/www/html/custom_apps \
-v config:/var/www/html/config \
-v data:/var/www/html/data \

View file

@ -1,16 +1,6 @@
#!/bin/sh
set -eu
# version_greater A B returns whether A > B
version_greater() {
[ "$(printf '%s\n' "$@" | sort -t '.' -n -k1,1 -k2,2 -k3,3 -k4,4 | head -n 1)" != "$1" ]
}
# return true if specified directory is empty
directory_empty() {
[ -z "$(ls -A "$1/")" ]
}
run_as() {
if [ "$(id -u)" = 0 ]; then
su -p www-data -s /bin/sh -c "$1"
@ -41,38 +31,11 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
} > /usr/local/etc/php/conf.d/redis-session.ini
fi
installed_version="0.0.0.0"
if [ -f /var/www/html/version.php ]; then
# shellcheck disable=SC2016
installed_version="$(php -r 'require "/var/www/html/version.php"; echo implode(".", $OC_Version);')"
fi
# shellcheck disable=SC2016
image_version="$(php -r 'require "/usr/src/nextcloud/version.php"; echo implode(".", $OC_Version);')"
if version_greater "$installed_version" "$image_version"; then
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?"
exit 1
fi
if version_greater "$image_version" "$installed_version"; then
echo "Initializing nextcloud $image_version ..."
if [ "$(id -u)" = 0 ]; then
rsync_options="-rlDog --chown www-data:root"
else
rsync_options="-rlD"
fi
rsync $rsync_options --delete --exclude-from=/upgrade.exclude /usr/src/nextcloud/ /var/www/html/
for dir in config data custom_apps themes; do
if [ ! -d "/var/www/html/$dir" ] || directory_empty "/var/www/html/$dir"; then
rsync $rsync_options --include "/$dir/" --exclude '/*' /usr/src/nextcloud/ /var/www/html/
fi
done
rsync $rsync_options --include '/version.php' --exclude '/*' /usr/src/nextcloud/ /var/www/html/
echo "Initializing finished"
#upgrade
if php occ status | grep installed | grep true; then
run_as 'php /var/www/html/occ upgrade'
#install
if [ "$installed_version" = "0.0.0.0" ]; then
else
echo "New nextcloud instance"
if [ -n "${NEXTCLOUD_ADMIN_USER+x}" ] && [ -n "${NEXTCLOUD_ADMIN_PASSWORD+x}" ]; then
@ -132,10 +95,6 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
echo "running web-based installer on first connect!"
fi
fi
#upgrade
else
run_as 'php /var/www/html/occ upgrade'
fi
fi
fi

View file

@ -141,9 +141,6 @@ function create_variant() {
cp "docker-$name.sh" "$dir/$name.sh"
done
# Copy the upgrade.exclude
cp upgrade.exclude "$dir/"
# Copy the config directory
cp -rT .config "$dir/config"

View file

@ -1,5 +0,0 @@
/config/
/data/
/custom_apps/
/themes/
/version.php