Skip to content
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

Apache no rsync #1548

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

ChristianKniep
Copy link

Some tweaks to the entrypoint and Dockerfile to not copy files that are tied to a version of nextcloud.
Instead use multiple volumes to hold r/w directories and make the rest of the container file-system r/o.

As discussed with @f7o

cd 21.0/apache
docker build -t nextcloud/apache:21.0.2 --build-arg=NEXTCLOUD_VERSION=21.0.2 .
docker build -t nextcloud/apache:21.0.3 --build-arg=NEXTCLOUD_VERSION=21.0.3 .
export NC_IMAGE_NAME=nextcloud/apache:21.0.2

Start the Stack

First we start the database in the background

$ docker-compose up -d db
Creating volume "apache_nextcloud_data" with default driver
Creating volume "apache_nextcloud_apps" with default driver
Creating volume "apache_nextcloud_config" with default driver
Creating volume "apache_nextcloud_themes" with default driver
Creating apache_db_1 ... done

Afterwards starting the nextcloud:21.0.2 instance

$ docker-compose up nextcloud 
apache_db_1 is up-to-date
Creating apache_nextcloud_1 ...
Attaching to apache_nextcloud_1
nextcloud_1  | + expr apache2-foreground : apache
nextcloud_1  | + [ -n  ]
nextcloud_1  | + expr apache2-foreground : apache
nextcloud_1  | + [ -n  ]
nextcloud_1  | + installed_version=0.0.0.0
nextcloud_1  | + php -r require "/var/www/html/version.php"; echo implode(".", $OC_Version);
nextcloud_1  | + image_version=21.0.2.1
...

Now we are able to open localhost:8000 and login as administrator/adminpass

Make some changes: added a user and some files.

We are going to stop the container (CTRL + C) and update to a new version.

$ export NC_IMAGE_NAME=nextcloud/apache:21.0.3
docker-compose up nextcloud

@@ -121,8 +122,8 @@ RUN a2enmod headers rewrite remoteip ;\
} > /etc/apache2/conf-available/remoteip.conf;\
a2enconf remoteip

ENV NEXTCLOUD_VERSION 21.0.3
Copy link
Author

Choose a reason for hiding this comment

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

Using ARG to be able to dynamically update the version without changing the Dockerfile.

Copy link
Contributor

Choose a reason for hiding this comment

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

ARG cannot be used in official images

&& mv /var/www/html/themes /usr/src/nextcloud/ \
&& mv /var/www/html/config /usr/src/nextcloud/

### Volumes
Copy link
Author

Choose a reason for hiding this comment

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

I use a bunch of VOLUMES to make explicit what directories need to be read/write.
In case they are not externally defined (see docker-compose.yml) they are going to contain what the container file-system has in that path up until that point.

Copy link
Contributor

Choose a reason for hiding this comment

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

Creating a bunch of VOLUMES is a bad practice. They are created on each run and there is no way to undefine them. You can create as many (read only) mounts as you need with --volume.

COPY config/* /usr/src/nextcloud/config/

ENTRYPOINT ["/entrypoint.sh"]
CMD ["apache2-foreground"]
ENTRYPOINT []
Copy link
Author

Choose a reason for hiding this comment

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

To make docker run possible, I switch to CMD.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is already possible due the exec "$@" in the entypoint script.

@J0WI
Copy link
Contributor

J0WI commented Aug 23, 2021

Thanks for your contribution. This contains some relatively invasive changes. Some of them violates the best practice requirements for official images. If there is no strong reason for these changes it's unlikely that we'll merge them.

@kniec
Copy link

kniec commented Aug 24, 2021

@J0WI Can you point me to the violations so that I can mitigate them?
IMHO this changes make the docker image more useable as it does not rsync all the files into a local volume.

@alexfornuto
Copy link

As someone who lost a lot of time and effort when the rsync nuked the mount point where I copied my data from an old host, I'd love to see some activity on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants