From 292b116cddf642f00d2924dab08598157129c14c Mon Sep 17 00:00:00 2001 From: Ethan Paul Date: Wed, 10 Apr 2024 23:15:34 -0400 Subject: [PATCH] Add in-container nextcloud install This increases the size of the container image, but reduces the reliance on the external volume for loading application data. This couples the application code to the container image rather than to the container state. --- nginx/Dockerfile | 20 +++++++++++++++++++- php-fpm/Dockerfile | 6 ++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/nginx/Dockerfile b/nginx/Dockerfile index 6ad0d66..4e47940 100644 --- a/nginx/Dockerfile +++ b/nginx/Dockerfile @@ -1,4 +1,15 @@ -FROM docker.io/library/nginx:latest +FROM docker.io/library/debian:latest AS unpack + +RUN apt-get update --yes +RUN apt-get install unzip --yes +RUN mkdir --parents /download + +WORKDIR /download + +ADD https://download.nextcloud.com/server/releases/latest.zip /download/latest.zip +RUN unzip latest.zip + +FROM docker.io/library/nginx:latest AS final ENV NEXTCLOUD_DOMAIN=example.com ENV NEXTCLOUD_PHP_FPM_HOST=php-fpm-nextcloud:9000 @@ -7,4 +18,11 @@ ENV NEXTCLOUD_MAX_UPLOAD_SIZE=512M ADD nginx.conf.template /nginx.conf.template ADD docker-entrypoint.sh /docker-entrypoint.sh +RUN mkdir --parents /var/www/html +WORKDIR /var/www/html + +COPY --from=unpack /download/nextcloud /var/www/html/nextcloud +RUN chown -R root:root nextcloud/ +RUN chmod -R 0755 nextcloud/ + ENTRYPOINT ["sh", "-c", "/docker-entrypoint.sh"] diff --git a/php-fpm/Dockerfile b/php-fpm/Dockerfile index 6db2d09..778d0d3 100644 --- a/php-fpm/Dockerfile +++ b/php-fpm/Dockerfile @@ -15,6 +15,7 @@ RUN apt-get update && apt-get install -y \ libldap2-dev \ libsmbclient-dev \ libcurl4-openssl-dev \ + unzip \ && rm -rf /var/lib/apt/lists/* # Download and install the docker-php-extension-installer script @@ -64,6 +65,11 @@ COPY ./php.ini-production /usr/local/etc/php/php.ini # Set the working directory WORKDIR /var/www/html +RUN curl -sSLo latest.zip https://download.nextcloud.com/server/releases/latest.zip +RUN unzip latest.zip +RUN rm latest.zip +RUN chown -R www-data:www-data nextcloud/ + # Expose port 9000 for PHP-FPM # EXPOSE 9000