From 99fccde008864a4711808b891e9bb4cec5a41cb4 Mon Sep 17 00:00:00 2001 From: Shihaam Abdul Rahman Date: Fri, 14 Feb 2025 03:48:31 +0500 Subject: [PATCH] fetch new and build new version automatically --- .build/ci-helper | 17 ++++++++ .build/compose.yml | 17 ++++++++ .build/docker-compose.yml | 15 ------- .build/entrypoint.sh | 21 ++++++++++ .build/fpm.Dockerfile | 31 --------------- .../get_latest_version.sh | 0 .build/nextcloud.Dockerfile | 39 +++++++++++++++++++ .build/nginx.conf | 3 ++ .build/php.ini | 4 +- README.md | 12 ++---- 10 files changed, 102 insertions(+), 57 deletions(-) create mode 100755 .build/ci-helper create mode 100644 .build/compose.yml delete mode 100644 .build/docker-compose.yml create mode 100755 .build/entrypoint.sh delete mode 100644 .build/fpm.Dockerfile rename get_latest_version.sh => .build/get_latest_version.sh (100%) create mode 100644 .build/nextcloud.Dockerfile diff --git a/.build/ci-helper b/.build/ci-helper new file mode 100755 index 0000000..e064220 --- /dev/null +++ b/.build/ci-helper @@ -0,0 +1,17 @@ +#!/bin/bash +cd "$(dirname "${BASH_SOURCE[0]}")" + +VERSION_JSON=$(./get_latest_version.sh) +NEXTCLOUD_VERSION=$(echo $VERSION_JSON | jq -r .version) +NEXTCLOUD_URL=$(echo $VERSION_JSON | jq -r .url) +NEXTCLOUD_FILENAME=$(echo $VERSION_JSON | jq -r .filename) + +export NEXTCLOUD_VERSION +export NEXTCLOUD_URL +export NEXTCLOUD_FILENAME + +echo "Nextcloud Version: $NEXTCLOUD_VERSION" +echo "Nextcloud URL: $NEXTCLOUD_URL" +echo "Nextcloud Filename: $NEXTCLOUD_FILENAME" + +docker compose $@ diff --git a/.build/compose.yml b/.build/compose.yml new file mode 100644 index 0000000..bf3069c --- /dev/null +++ b/.build/compose.yml @@ -0,0 +1,17 @@ +services: + nextcloud: + build: + context: . + dockerfile: nextcloud.Dockerfile + args: + NEXTCLOUD_VERSION: ${NEXTCLOUD_VERSION} + NEXTCLOUD_URL: ${NEXTCLOUD_URL} + NEXTCLOUD_FILENAME: ${NEXTCLOUD_FILENAME} + hostname: nextcloud + image: git.shihaam.dev/dockerfiles/nextcloud/nextcloud:${NEXTCLOUD_VERSION} + nginx: + build: + context: . + dockerfile: nginx.Dockerfile + hostname: nginx + image: git.shihaam.dev/dockerfiles/nextcloud/nginx diff --git a/.build/docker-compose.yml b/.build/docker-compose.yml deleted file mode 100644 index 3849ac1..0000000 --- a/.build/docker-compose.yml +++ /dev/null @@ -1,15 +0,0 @@ -services: - fpm: - build: - context: . - dockerfile: fpm.Dockerfile - args: - - VERSION=29.0.3 - hostname: fpm - image: git.shihaam.dev/dockerfiles/nextcloud/fpm:29.0.3 - nginx: - build: - context: . - dockerfile: nginx.Dockerfile - hostname: nginx - image: git.shihaam.dev/dockerfiles/nextcloud/nginx diff --git a/.build/entrypoint.sh b/.build/entrypoint.sh new file mode 100755 index 0000000..256c238 --- /dev/null +++ b/.build/entrypoint.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +if [ ! -f /var/www/html/config/config.php ]; then + touch /var/www/html/config/CAN_INSTALL + cp /var/www/default_config.sample.php /var/www/html/config/config.sample.php + echo "Created /var/www/html/config/CAN_INSTALL and config.sample.php because config.php does not exist." +else + echo "config.php exists. No action taken." +fi + +if [ -z "$(ls -A /var/www/html/apps)" ]; then + cp -r /var/www/default_apps/* /var/www/html/apps/ + echo "Copied default apps to /var/www/html/apps because it was empty." +else + echo "/var/www/html/apps is not empty. No action taken." +fi + +## Set permissions +chown -R www-data:www-data /var/www/html/ + +exec "$@" diff --git a/.build/fpm.Dockerfile b/.build/fpm.Dockerfile deleted file mode 100644 index 4540df4..0000000 --- a/.build/fpm.Dockerfile +++ /dev/null @@ -1,31 +0,0 @@ -FROM git.shihaam.dev/dockerfiles/php-fpm:8.3 - -LABEL maintainer="Shiham Abdul Rahman " -LABEL org.opencontainers.image.source="https://git.shihaam.dev/dockerfiles/nextcloud" -LABEL org.opencontainers.image.documentation="https://git.shihaam.dev/dockerfiles/nextcloud" -LABEL org.opencontainers.image.description="A simplified docker image for nextcloud" - -ARG URL=https://download.nextcloud.com/server/releases/ -ARG VERSION -WORKDIR /var/www/html -SHELL ["/bin/bash", "-c"] - -# Download, Extract and Delete nextcloud tar.bz2 -RUN curl ${URL}nextcloud-${VERSION}.tar.bz2 -o nextcloud-${VERSION}.tar.bz2 \ - && tar -vxjf nextcloud-${VERSION}.tar.bz2 \ - && mv -v nextcloud/* . \ - && rm -rv nextcloud nextcloud-${VERSION}.tar.bz2 - -# Installing basic tools -RUN apt-get update && apt-get install bzip2 zip unzip git gnupg2 ca-certificates lsb-release apt-transport-https wget curl nano vim -y --no-install-recommends \ - && apt-get auto-remove -y \ - && apt-get clean -y - -# Copy php.ini config -COPY php.ini /usr/local/etc/php/php.ini - -# Install Php stuff -RUN docker-php-ext-install {gd,mysqli,pdo,pdo_mysql,bcmath,calendar,zip,gettext,exif,pcntl,shmop,-j$(nproc),gd,sysvmsg,sysvsem,sysvshm} - -# export volume for nginx to serve static files -VOLUME /var/www/html diff --git a/get_latest_version.sh b/.build/get_latest_version.sh similarity index 100% rename from get_latest_version.sh rename to .build/get_latest_version.sh diff --git a/.build/nextcloud.Dockerfile b/.build/nextcloud.Dockerfile new file mode 100644 index 0000000..eb70292 --- /dev/null +++ b/.build/nextcloud.Dockerfile @@ -0,0 +1,39 @@ +FROM git.shihaam.dev/dockerfiles/php-fpm:8.3 + +ARG NEXTCLOUD_VERSION +ARG NEXTCLOUD_URL +ARG NEXTCLOUD_FILENAME + +WORKDIR /var/www/html +SHELL ["/bin/bash", "-c"] + +# Installing basic tools +RUN apt-get update \ + && apt-get install {bzip2,zip,unzip,gnupg2,ca-certificates,lsb-release,apt-transport-https,wget,curl,nano} -y --no-install-recommends \ + && apt-get auto-remove -y \ + && apt-get clean -y + +# Download, Extract and Delete nextcloud tar.bz2 +RUN wget $NEXTCLOUD_URL \ + && tar -vxjf $NEXTCLOUD_FILENAME \ + && mv -v nextcloud/* . \ + && rm -rv nextcloud $NEXTCLOUD_FILENAME + +# install php plugins +RUN docker-php-ext-install {gd,mysqli,pdo,pdo_mysql,bcmath,calendar,zip,gettext,exif,pcntl,shmop,-j$(nproc),gd,sysvmsg,sysvsem,sysvshm} + +## copy default config and apps for setup in entrypoint +RUN mv /var/www/html/config/config.sample.php /var/www/default_config.sample.php \ + && mv /var/www/html/apps/ /var/www/default_apps/ + +# copy php config +COPY php.ini /usr/local/etc/php/php.ini + +# copy and setup entrypoint +COPY entrypoint.sh /usr/local/bin/entrypoint.sh +ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] + +# export volume for nginx to serve static files +VOLUME /var/www/html + +CMD ["php-fpm"] diff --git a/.build/nginx.conf b/.build/nginx.conf index fa1d7d6..506a1c7 100644 --- a/.build/nginx.conf +++ b/.build/nginx.conf @@ -31,6 +31,9 @@ server { client_max_body_size 4G; client_body_timeout 600s; fastcgi_buffers 64 4K; + fastcgi_read_timeout 300; + fastcgi_send_timeout 300; + fastcgi_connect_timeout 300; # Enable gzip but do not remove ETag headers gzip on; diff --git a/.build/php.ini b/.build/php.ini index 283da49..e7a5a90 100644 --- a/.build/php.ini +++ b/.build/php.ini @@ -385,7 +385,7 @@ expose_php = On ; Maximum execution time of each script, in seconds ; http://php.net/max-execution-time ; Note: This directive is hardcoded to 0 for the CLI SAPI -max_execution_time = 30 +max_execution_time = 300 ; Maximum amount of time each script may spend parsing request data. It's a good ; idea to limit this time on productions servers in order to eliminate unexpectedly @@ -395,7 +395,7 @@ max_execution_time = 30 ; Development Value: 60 (60 seconds) ; Production Value: 60 (60 seconds) ; http://php.net/max-input-time -max_input_time = 60 +max_input_time = 300 ; Maximum input variable nesting level ; http://php.net/max-input-nesting-level diff --git a/README.md b/README.md index 8080667..cfb451d 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,8 @@ services: image: git.shihaam.dev/dockerfiles/nextcloud/fpm:latest hostname: fpm volumes: - - nextcloud-config:/var/www/html/config:rw - - nextcloud-apps:/var/www/html/apps:rw + - ./nextcloud/config:/var/www/html/config:rw + - ./nextcloud/apps:/var/www/html/apps:rw - /mnt/vol0/nextcloud-data:/var/www/html/data:rw depends_on: - mysql @@ -34,11 +34,7 @@ services: MYSQL_PASSWORD: nextcloud MYSQL_ALLOW_EMPTY_PASSWORD: true volumes: - - ./database:/var/lib/mysql - -volumes: - nextcloud-config: - nextcloud-apps: + - ./nextcloud/database:/var/lib/mysql ``` - You must use a reverse proxy with SSL before starting to setup, personally i use nginx with certbot. \ @@ -61,5 +57,3 @@ server { sudo certbot --nginx -d nextcloud.shihaam.me ``` - Configure your DNS accordingly and then.. thats it, enjoy. - -