|
| 1 | +FROM php:8.4-apache-trixie |
| 2 | + |
| 3 | +ARG GIT_REF=master |
| 4 | +ARG NEXTCLOUD_REPO=https://github.com/nextcloud/server.git |
| 5 | +ARG NODE_VERSION=25.2.1 |
| 6 | + |
| 7 | +RUN apt-get update && apt-get install -y --no-install-recommends \ |
| 8 | + git unzip rsync nano less \ |
| 9 | + libpng-dev libjpeg62-turbo-dev libfreetype6-dev \ |
| 10 | + libzip-dev libxml2-dev libicu-dev libgmp-dev \ |
| 11 | + libbz2-dev libexif-dev libwebp-dev \ |
| 12 | + libmagickwand-dev util-linux sudo \ |
| 13 | + ca-certificates curl \ |
| 14 | + && rm -rf /var/lib/apt/lists/* |
| 15 | + |
| 16 | + |
| 17 | +RUN set -eux; \ |
| 18 | + arch="$(dpkg --print-architecture)"; \ |
| 19 | + case "$arch" in \ |
| 20 | + amd64) node_arch='x64' ;; \ |
| 21 | + arm64) node_arch='arm64' ;; \ |
| 22 | + armhf) node_arch='armv7l' ;; \ |
| 23 | + *) echo "Unsupported architecture: $arch"; exit 1 ;; \ |
| 24 | + esac; \ |
| 25 | + curl -fsSLO "https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-${node_arch}.tar.xz"; \ |
| 26 | + tar -xJf "node-v${NODE_VERSION}-linux-${node_arch}.tar.xz" -C /usr/local --strip-components=1 --no-same-owner; \ |
| 27 | + rm "node-v${NODE_VERSION}-linux-${node_arch}.tar.xz"; \ |
| 28 | + ln -s /usr/local/bin/node /usr/local/bin/nodejs |
| 29 | + |
| 30 | +RUN docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp \ |
| 31 | + && docker-php-ext-install -j"$(nproc)" \ |
| 32 | + gd \ |
| 33 | + bcmath \ |
| 34 | + bz2 \ |
| 35 | + exif \ |
| 36 | + intl \ |
| 37 | + gmp \ |
| 38 | + opcache \ |
| 39 | + pcntl \ |
| 40 | + pdo_mysql \ |
| 41 | + zip \ |
| 42 | + xml \ |
| 43 | + mysqli |
| 44 | + |
| 45 | + |
| 46 | +RUN pecl install redis apcu && docker-php-ext-enable redis apcu |
| 47 | + |
| 48 | +RUN pecl install imagick && docker-php-ext-enable imagick || true |
| 49 | + |
| 50 | +RUN a2enmod rewrite headers env dir mime setenvif |
| 51 | + |
| 52 | +RUN mkdir /var/www/.npm && sudo chown -R www-data:www-data /var/www/.npm |
| 53 | +RUN mkdir mkdir /var/www/.cache && sudo chown -R www-data:www-data /var/www/.cache |
| 54 | + |
| 55 | +RUN { \ |
| 56 | + echo "memory_limit=512M"; \ |
| 57 | + echo "upload_max_filesize=512M"; \ |
| 58 | + echo "post_max_size=512M"; \ |
| 59 | + echo "max_execution_time=360"; \ |
| 60 | + echo "output_buffering=0"; \ |
| 61 | +} > /usr/local/etc/php/conf.d/nextcloud.ini |
| 62 | + |
| 63 | +RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \ |
| 64 | + && php composer-setup.php --install-dir=/usr/local/bin --filename=composer \ |
| 65 | + && rm composer-setup.php |
| 66 | + |
| 67 | +#COPY nextcloud/ ./ |
| 68 | +#RUN git clone --single-branch --depth=1 --branch "$GIT_REF" --recurse-submodules "$NEXTCLOUD_REPO" /usr/src/nextcloud |
| 69 | +RUN set -eux; \ |
| 70 | + git init /usr/src/nextcloud; \ |
| 71 | + cd /usr/src/nextcloud; \ |
| 72 | + git remote add origin "$NEXTCLOUD_REPO"; \ |
| 73 | + if echo "$GIT_REF" | grep -Eq '^[0-9a-f]{7,40}$'; then \ |
| 74 | + # GIT_REF looks like a commit SHA |
| 75 | + git fetch --depth=1 origin "$GIT_REF"; \ |
| 76 | + git checkout --detach FETCH_HEAD; \ |
| 77 | + else \ |
| 78 | + # GIT_REF is a branch or tag |
| 79 | + git fetch --depth=1 --tags origin "$GIT_REF"; \ |
| 80 | + git checkout -q "$GIT_REF"; \ |
| 81 | + fi; \ |
| 82 | + # bring in submodules shallowly |
| 83 | + git submodule update --init --recursive --depth=1 |
| 84 | + |
| 85 | +WORKDIR /usr/src/nextcloud |
| 86 | + |
| 87 | + |
| 88 | +RUN if [ -d .git ]; then \ |
| 89 | + git remote set-url origin "$NEXTCLOUD_REPO" || true; \ |
| 90 | + fi |
| 91 | + |
| 92 | +# RUN if [ -d .git ]; then \ |
| 93 | +# git fetch --all --tags; \ |
| 94 | +# git checkout "$GIT_REF"; \ |
| 95 | +# git submodule update --init --recursive; \ |
| 96 | +# else \ |
| 97 | +# echo "WARNING: ./nextcloud has no .git; skipping fetch/checkout/submodules"; \ |
| 98 | +# fi |
| 99 | + |
| 100 | +ENV COMPOSER_ALLOW_SUPERUSER=1 |
| 101 | +RUN if [ -f composer.json ]; then composer install --no-dev -o --no-interaction --no-ansi || true; fi |
| 102 | + |
| 103 | + |
| 104 | +WORKDIR /var/www/html |
| 105 | +RUN rm -rf /var/www/html/* \ |
| 106 | + && rsync -a /usr/src/nextcloud/ /var/www/html/ \ |
| 107 | + && chown -R www-data:www-data /var/www/html |
| 108 | + |
| 109 | +RUN mkdir -p /var/www/html/config /var/www/html/data /var/www/html/custom_apps /var/www/html/themes \ |
| 110 | + && chown -R www-data:www-data /var/www/html |
| 111 | + |
| 112 | + |
| 113 | +HEALTHCHECK --interval=30s --timeout=10s --retries=10 \ |
| 114 | + CMD php -r 'echo file_exists("/var/www/html/index.php") ? "OK" : "NO";' | grep -q OK || exit 1 |
| 115 | + |
| 116 | +COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh |
| 117 | +RUN chmod +x /usr/local/bin/docker-entrypoint.sh |
| 118 | +ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"] |
| 119 | + |
| 120 | +EXPOSE 80 |
| 121 | +CMD ["apache2-foreground"] |
0 commit comments