Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion 10.0/apache/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
FROM php:5.6-apache

RUN apt-get update && apt-get install -y \
rsync \
bzip2 \
libcurl4-openssl-dev \
libfreetype6-dev \
Expand Down Expand Up @@ -52,9 +53,11 @@ RUN curl -fsSL -o nextcloud.tar.bz2 \
&& gpg --batch --verify nextcloud.tar.bz2.asc nextcloud.tar.bz2 \
&& rm -r "$GNUPGHOME" nextcloud.tar.bz2.asc \
&& tar -xjf nextcloud.tar.bz2 -C /usr/src/ \
&& rm nextcloud.tar.bz2
&& rm nextcloud.tar.bz2 \
&& rm -rf /usr/src/nextcloud/updater

COPY docker-entrypoint.sh /entrypoint.sh
COPY apps.config.php /usr/src/nextcloud/config/apps.config.php

ENTRYPOINT ["/entrypoint.sh"]
CMD ["apache2-foreground"]
15 changes: 15 additions & 0 deletions 10.0/apache/apps.config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php
$CONFIG = array (
"apps_paths" => array (
0 => array (
"path" => OC::$SERVERROOT."/apps",
"url" => "/apps",
"writable" => false,
),
1 => array (
"path" => OC::$SERVERROOT."/custom_apps",
"url" => "/custom_apps",
"writable" => true,
),
),
);
40 changes: 38 additions & 2 deletions 10.0/apache/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,45 @@
#!/bin/bash
set -e

if [ ! -e '/var/www/html/version.php' ]; then
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" ]];
Copy link
Copy Markdown
Member

@pierreozoux pierreozoux Apr 19, 2017

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

Copy link
Copy Markdown
Contributor

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...

Copy link
Copy Markdown
Member

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.

}

installed_version="0.0.0~unknown"
if [ -f /var/www/html/version.php ]; then
installed_version=$(php -r 'require "/var/www/html/version.php"; echo "$OC_VersionString";')
fi
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"
Copy link
Copy Markdown
Contributor

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?"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

exit 1
fi

if version_greater "$image_version" "$installed_version"; then
if [ "$installed_version" != "0.0.0~unknown" ]; then
su - www-data -s /bin/bash -c 'php /var/www/html/occ app:list' > /tmp/list_before
fi

rsync -a --delete --exclude /config/ --exclude /data/ --exclude /custom_apps/ /usr/src/nextcloud/ /var/www/html/

if [ ! -d /var/www/html/config ]; then
cp -arT /usr/src/nextcloud/config /var/www/html/config
fi

mkdir -p /var/www/html/custom_apps

chown -R www-data /var/www/html

if [ "$installed_version" != "0.0.0~unknown" ]; then
su - www-data -s /bin/bash -c 'php /var/www/html/occ upgrade --no-app-disable'

su - www-data -s /bin/bash -c 'php /var/www/html/occ app:list' > /tmp/list_after
echo "The following apps have beed disabled:"
diff <(sed -n "/Enabled:/,/Disabled:/p" /tmp/list_before) <(sed -n "/Enabled:/,/Disabled:/p" /tmp/list_after) | grep '<' | cut -d- -f2 | cut -d: -f1
rm -f /tmp/list_before /tmp/list_after
fi
fi

exec "$@"
5 changes: 4 additions & 1 deletion 10.0/fpm/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
FROM php:5.6-fpm

RUN apt-get update && apt-get install -y \
rsync \
bzip2 \
libcurl4-openssl-dev \
libfreetype6-dev \
Expand Down Expand Up @@ -50,9 +51,11 @@ RUN curl -fsSL -o nextcloud.tar.bz2 \
&& gpg --batch --verify nextcloud.tar.bz2.asc nextcloud.tar.bz2 \
&& rm -r "$GNUPGHOME" nextcloud.tar.bz2.asc \
&& tar -xjf nextcloud.tar.bz2 -C /usr/src/ \
&& rm nextcloud.tar.bz2
&& rm nextcloud.tar.bz2 \
&& rm -rf /usr/src/nextcloud/updater

COPY docker-entrypoint.sh /entrypoint.sh
COPY apps.config.php /usr/src/nextcloud/config/apps.config.php

ENTRYPOINT ["/entrypoint.sh"]
CMD ["php-fpm"]
15 changes: 15 additions & 0 deletions 10.0/fpm/apps.config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php
$CONFIG = array (
"apps_paths" => array (
0 => array (
"path" => OC::$SERVERROOT."/apps",
"url" => "/apps",
"writable" => false,
),
1 => array (
"path" => OC::$SERVERROOT."/custom_apps",
"url" => "/custom_apps",
"writable" => true,
),
),
);
40 changes: 38 additions & 2 deletions 10.0/fpm/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,45 @@
#!/bin/bash
set -e

if [ ! -e '/var/www/html/version.php' ]; then
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" ]];
}

installed_version="0.0.0~unknown"
if [ -f /var/www/html/version.php ]; then
installed_version=$(php -r 'require "/var/www/html/version.php"; echo "$OC_VersionString";')
fi
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"
exit 1
fi

if version_greater "$image_version" "$installed_version"; then
if [ "$installed_version" != "0.0.0~unknown" ]; then
su - www-data -s /bin/bash -c 'php /var/www/html/occ app:list' > /tmp/list_before
fi

rsync -a --delete --exclude /config/ --exclude /data/ --exclude /custom_apps/ /usr/src/nextcloud/ /var/www/html/

if [ ! -d /var/www/html/config ]; then
cp -arT /usr/src/nextcloud/config /var/www/html/config
fi

mkdir -p /var/www/html/custom_apps

chown -R www-data /var/www/html

if [ "$installed_version" != "0.0.0~unknown" ]; then
su - www-data -s /bin/bash -c 'php /var/www/html/occ upgrade --no-app-disable'

su - www-data -s /bin/bash -c 'php /var/www/html/occ app:list' > /tmp/list_after
echo "The following apps have beed disabled:"
diff <(sed -n "/Enabled:/,/Disabled:/p" /tmp/list_before) <(sed -n "/Enabled:/,/Disabled:/p" /tmp/list_after) | grep '<' | cut -d- -f2 | cut -d: -f1
rm -f /tmp/list_before /tmp/list_after
fi
fi

exec "$@"
5 changes: 4 additions & 1 deletion 11.0/apache/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
FROM php:7.1-apache

RUN apt-get update && apt-get install -y \
rsync \
bzip2 \
libcurl4-openssl-dev \
libfreetype6-dev \
Expand Down Expand Up @@ -52,9 +53,11 @@ RUN curl -fsSL -o nextcloud.tar.bz2 \
&& gpg --batch --verify nextcloud.tar.bz2.asc nextcloud.tar.bz2 \
&& rm -r "$GNUPGHOME" nextcloud.tar.bz2.asc \
&& tar -xjf nextcloud.tar.bz2 -C /usr/src/ \
&& rm nextcloud.tar.bz2
&& rm nextcloud.tar.bz2 \
&& rm -rf /usr/src/nextcloud/updater

COPY docker-entrypoint.sh /entrypoint.sh
COPY apps.config.php /usr/src/nextcloud/config/apps.config.php

ENTRYPOINT ["/entrypoint.sh"]
CMD ["apache2-foreground"]
15 changes: 15 additions & 0 deletions 11.0/apache/apps.config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php
$CONFIG = array (
"apps_paths" => array (
0 => array (
"path" => OC::$SERVERROOT."/apps",
"url" => "/apps",
"writable" => false,
),
1 => array (
"path" => OC::$SERVERROOT."/custom_apps",
"url" => "/custom_apps",
"writable" => true,
),
),
);
40 changes: 38 additions & 2 deletions 11.0/apache/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,45 @@
#!/bin/bash
set -e

if [ ! -e '/var/www/html/version.php' ]; then
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" ]];
}

installed_version="0.0.0~unknown"
if [ -f /var/www/html/version.php ]; then
installed_version=$(php -r 'require "/var/www/html/version.php"; echo "$OC_VersionString";')
fi
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"
exit 1
fi

if version_greater "$image_version" "$installed_version"; then
if [ "$installed_version" != "0.0.0~unknown" ]; then
su - www-data -s /bin/bash -c 'php /var/www/html/occ app:list' > /tmp/list_before
fi

rsync -a --delete --exclude /config/ --exclude /data/ --exclude /custom_apps/ /usr/src/nextcloud/ /var/www/html/

if [ ! -d /var/www/html/config ]; then
cp -arT /usr/src/nextcloud/config /var/www/html/config
fi

mkdir -p /var/www/html/custom_apps

chown -R www-data /var/www/html

if [ "$installed_version" != "0.0.0~unknown" ]; then
su - www-data -s /bin/bash -c 'php /var/www/html/occ upgrade --no-app-disable'

su - www-data -s /bin/bash -c 'php /var/www/html/occ app:list' > /tmp/list_after
echo "The following apps have beed disabled:"
diff <(sed -n "/Enabled:/,/Disabled:/p" /tmp/list_before) <(sed -n "/Enabled:/,/Disabled:/p" /tmp/list_after) | grep '<' | cut -d- -f2 | cut -d: -f1
rm -f /tmp/list_before /tmp/list_after
fi
fi

exec "$@"
5 changes: 4 additions & 1 deletion 11.0/fpm/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
FROM php:7.1-fpm

RUN apt-get update && apt-get install -y \
rsync \
bzip2 \
libcurl4-openssl-dev \
libfreetype6-dev \
Expand Down Expand Up @@ -50,9 +51,11 @@ RUN curl -fsSL -o nextcloud.tar.bz2 \
&& gpg --batch --verify nextcloud.tar.bz2.asc nextcloud.tar.bz2 \
&& rm -r "$GNUPGHOME" nextcloud.tar.bz2.asc \
&& tar -xjf nextcloud.tar.bz2 -C /usr/src/ \
&& rm nextcloud.tar.bz2
&& rm nextcloud.tar.bz2 \
&& rm -rf /usr/src/nextcloud/updater

COPY docker-entrypoint.sh /entrypoint.sh
COPY apps.config.php /usr/src/nextcloud/config/apps.config.php

ENTRYPOINT ["/entrypoint.sh"]
CMD ["php-fpm"]
15 changes: 15 additions & 0 deletions 11.0/fpm/apps.config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php
$CONFIG = array (
"apps_paths" => array (
0 => array (
"path" => OC::$SERVERROOT."/apps",
"url" => "/apps",
"writable" => false,
),
1 => array (
"path" => OC::$SERVERROOT."/custom_apps",
"url" => "/custom_apps",
"writable" => true,
),
),
);
40 changes: 38 additions & 2 deletions 11.0/fpm/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,45 @@
#!/bin/bash
set -e

if [ ! -e '/var/www/html/version.php' ]; then
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" ]];
}

installed_version="0.0.0~unknown"
if [ -f /var/www/html/version.php ]; then
installed_version=$(php -r 'require "/var/www/html/version.php"; echo "$OC_VersionString";')
fi
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"
exit 1
fi

if version_greater "$image_version" "$installed_version"; then
if [ "$installed_version" != "0.0.0~unknown" ]; then
su - www-data -s /bin/bash -c 'php /var/www/html/occ app:list' > /tmp/list_before
fi

rsync -a --delete --exclude /config/ --exclude /data/ --exclude /custom_apps/ /usr/src/nextcloud/ /var/www/html/

if [ ! -d /var/www/html/config ]; then
cp -arT /usr/src/nextcloud/config /var/www/html/config
fi

mkdir -p /var/www/html/custom_apps

chown -R www-data /var/www/html

if [ "$installed_version" != "0.0.0~unknown" ]; then
su - www-data -s /bin/bash -c 'php /var/www/html/occ upgrade --no-app-disable'

su - www-data -s /bin/bash -c 'php /var/www/html/occ app:list' > /tmp/list_after
echo "The following apps have beed disabled:"
diff <(sed -n "/Enabled:/,/Disabled:/p" /tmp/list_before) <(sed -n "/Enabled:/,/Disabled:/p" /tmp/list_after) | grep '<' | cut -d- -f2 | cut -d: -f1
rm -f /tmp/list_before /tmp/list_after
fi
fi

exec "$@"
5 changes: 4 additions & 1 deletion 9.0/apache/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
FROM php:5.6-apache

RUN apt-get update && apt-get install -y \
rsync \
bzip2 \
libcurl4-openssl-dev \
libfreetype6-dev \
Expand Down Expand Up @@ -52,9 +53,11 @@ RUN curl -fsSL -o nextcloud.tar.bz2 \
&& gpg --batch --verify nextcloud.tar.bz2.asc nextcloud.tar.bz2 \
&& rm -r "$GNUPGHOME" nextcloud.tar.bz2.asc \
&& tar -xjf nextcloud.tar.bz2 -C /usr/src/ \
&& rm nextcloud.tar.bz2
&& rm nextcloud.tar.bz2 \
&& rm -rf /usr/src/nextcloud/updater

COPY docker-entrypoint.sh /entrypoint.sh
COPY apps.config.php /usr/src/nextcloud/config/apps.config.php

ENTRYPOINT ["/entrypoint.sh"]
CMD ["apache2-foreground"]
15 changes: 15 additions & 0 deletions 9.0/apache/apps.config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php
$CONFIG = array (
"apps_paths" => array (
0 => array (
"path" => OC::$SERVERROOT."/apps",
"url" => "/apps",
"writable" => false,
),
1 => array (
"path" => OC::$SERVERROOT."/custom_apps",
"url" => "/custom_apps",
"writable" => true,
),
),
);
Loading