From: Vincent Vanwaelscappel Date: Sat, 27 Aug 2022 13:46:50 +0000 (+0200) Subject: wip #5418 @1 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=e530d3690ceda5dbc0322d4e5cb9d70d9ba97575;p=fluidbook-toolbox.git wip #5418 @1 --- diff --git a/.docker/config/crontab b/.docker/config/crontab index d8ce4b2c5..4acd6f4ad 100644 --- a/.docker/config/crontab +++ b/.docker/config/crontab @@ -3,5 +3,4 @@ SHELL=/bin/sh PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin * * * * * runuser -l toolbox -c '/usr/bin/php /application/artisan schedule:run' > /proc/1/fd/1 2>/proc/1/fd/2 -* * * * * echo 'Test cron' > /proc/1/fd/1 2>/proc/1/fd/2 20 5 * * * /application/scripts/restartworkers > /proc/1/fd/1 2>/proc/1/fd/2 diff --git a/.docker/config/httpd/httpd.conf b/.docker/config/httpd/httpd.conf index 1126f6cdc..af7775faf 100644 --- a/.docker/config/httpd/httpd.conf +++ b/.docker/config/httpd/httpd.conf @@ -198,6 +198,8 @@ LoadModule dir_module modules/mod_dir.so LoadModule alias_module modules/mod_alias.so LoadModule rewrite_module modules/mod_rewrite.so +LoadModule xsendfile_module /usr/lib/apache2/modules/mod_xsendfile.so + # # If you wish httpd to run as a different user or group, you must run @@ -293,6 +295,12 @@ DocumentRoot "/usr/local/apache2/htdocs" ProxyPassMatch ^/(.*\.php(/.*)?)$ "fcgi://fluidbook-toolbox:9000/application/public/$1" timeout=1800 +XSendFile on +XSendFilePath /data1/extranet +XSendFilePath /application +XSendFilePath /home/extranet + + # # DirectoryIndex: sets the file that Apache will serve if a directory # is requested. diff --git a/.docker/docker-compose.yml b/.docker/docker-compose.yml index 676732bee..c11943842 100644 --- a/.docker/docker-compose.yml +++ b/.docker/docker-compose.yml @@ -2,11 +2,12 @@ version: '3.1' services: webserver: container_name: fluidbook-toolbox-httpd - image: 'httpd:alpine' + build: /data1/extranet/toolbox/.docker/images/httpd working_dir: /application volumes: - - '/data1/extranet/toolbox/public/:/usr/local/apache2/htdocs/' - - '/data1/extranet/toolbox/.docker/config/httpd/httpd.conf:/usr/local/apache2/conf/httpd.conf' + - '/data1/extranet/toolbox/:/application/' + - '/data1/extranet/toolbox/public/:/usr/local/apache2/htdocs/' + - '/data1/extranet/toolbox/.docker/config/httpd/httpd.conf:/usr/local/apache2/conf/httpd.conf' ports: - '37126:80' environment: @@ -18,7 +19,7 @@ services: php-fpm: container_name: fluidbook-toolbox - build: /data1/extranet/toolbox/.docker/image + build: /data1/extranet/toolbox/.docker/images/php working_dir: /application volumes: - '/data1/extranet/toolbox/.docker/config/ssh/:/root/.ssh/' diff --git a/.docker/image/Dockerfile b/.docker/image/Dockerfile deleted file mode 100644 index 84b58c3e9..000000000 --- a/.docker/image/Dockerfile +++ /dev/null @@ -1,95 +0,0 @@ -############################################ -# PHPDocker.io PHP 8.1 / CLI and FPM image # -############################################ - -FROM ubuntu:jammy AS cli - -WORKDIR "/application" - -# Fixes some weird terminal issues such as broken clear / CTRL+L -ENV TERM=linux - -# Ensure apt doesn't ask questions when installing stuff -ENV DEBIAN_FRONTEND=noninteractive - -# Install Ondrej repos for Ubuntu jammy, PHP, composer and selected extensions - better selection than -# the distro's packages -RUN apt-get update && apt-get install -y --no-install-recommends gnupg \ - && echo "deb http://ppa.launchpad.net/ondrej/php/ubuntu jammy main" > /etc/apt/sources.list.d/ondrej-php.list \ - && apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4F4EA0AAE5267A6C \ - && apt-get update \ - && apt-get -y --no-install-recommends install \ - ca-certificates \ - curl \ - unzip \ - git \ - php8.1-apcu \ - php8.1-cli \ - php8.1-curl \ - php8.1-mbstring \ - php8.1-opcache \ - php8.1-readline \ - php8.1-xml \ - php8.1-zip \ - php8.1-bz2 \ - php8.1-gd \ - php8.1-igbinary \ - php8.1-imap \ - php8.1-imagick \ - php8.1-intl \ - php8.1-memcached \ - php8.1-mysql \ - php8.1-redis \ - php8.1-soap \ - php8.1-ssh2 \ - php8.1-tidy \ - php8.1-xsl \ - php8.1-curl \ - php8.1-mcrypt \ - less nano wget bash lynx - -COPY --from=composer:2 /usr/bin/composer /usr/bin/composer - -CMD ["php", "-a"] - -# If you'd like to be able to use this container on a docker-compose environment as a quiescent PHP CLI container -# you can /bin/bash into, override CMD with the following - bear in mind that this will make docker-compose stop -# slow on such a container, docker-compose kill might do if you're in a hurry -# CMD ["tail", "-f", "/dev/null"] - -FROM cli AS fpm - -# Install FPM -RUN apt-get update \ - && apt-get -y --no-install-recommends install php8.1-fpm - -STOPSIGNAL SIGQUIT - -# Toolbox -RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash - && apt-get install -y nodejs - -RUN apt-get -y --no-install-recommends install sudo -RUN apt-get -y --no-install-recommends install supervisor ssh rsync -RUN apt-get -y --no-install-recommends install nsis -RUN apt-get -y --no-install-recommends install default-jre pdftk poppler-utils ghostscript imagemagick netpbm libjpeg-turbo8 -RUN apt-get -y --no-install-recommends install zip unzip gzip 7zip -RUN apt-get -y --no-install-recommends install icoutils fontforge -RUN apt-get -y --no-install-recommends install ffmpeg python3 -RUN apt-get -y --no-install-recommends install inkscape mupdf-tools -RUN apt-get -y --no-install-recommends install cron - -RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* -RUN curl -L https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp -o /usr/local/bin/yt-dlp && chmod a+rx /usr/local/bin/yt-dlp && ln -s /usr/local/bin/yt-dlp /usr/local/bin/youtube-dl - -RUN useradd -d /application -g www-data -s /bin/bash -u 1001 toolbox -RUN npm install --unsafe-perm --global uglify-js less puppeteer - -# PHP-FPM packages need a nudge to make them docker-friendly -COPY overrides.conf /etc/php/8.1/fpm/pool.d/z-overrides.conf - -#CMD ["/usr/sbin/php-fpm8.1", "-O" ] -COPY startup /usr/bin/startup -CMD exec /usr/bin/startup - -# Open up fcgi port -EXPOSE 9000 diff --git a/.docker/image/overrides.conf b/.docker/image/overrides.conf deleted file mode 100644 index 5d60f05fb..000000000 --- a/.docker/image/overrides.conf +++ /dev/null @@ -1,37 +0,0 @@ -[global] -; Override default pid file -pid = /run/php-fpm.pid - -; Avoid logs being sent to syslog -error_log = /proc/self/fd/2 - -; Set this to php default's max_execution_time to allow children to stop gracefully when fpm is commanded to stop -; This helps avoiding 502's -process_control_timeout = 30 - -; Do not daemonize (eg send process to the background) -daemonize = no - -[www] -; Access from webserver container is via network, not socket file -listen = [::]:9000 - -; Redirect logs to stdout - FPM closes /dev/std* on startup -access.log = /proc/self/fd/2 -catch_workers_output = yes - -; Remove "pool www" decoration from log output (older phpdocker.io containers for php use sed for this) -decorate_workers_output = no - -; Required to allow config-by-environment -clear_env = no - -user = 1001 -group = 33 - -pm = dynamic -pm.max_children = 80 -pm.start_servers = 24 -pm.min_spare_servers = 20 -pm.max_spare_servers = 40 -pm.max_requests = 1000 diff --git a/.docker/image/startup b/.docker/image/startup deleted file mode 100644 index d2ec45531..000000000 --- a/.docker/image/startup +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -chmod 0644 /etc/crontab && crontab -u root /etc/crontab -/usr/sbin/service cron start -/usr/sbin/service supervisor start -/usr/sbin/php-fpm8.1 -O diff --git a/.docker/images/httpd/Dockerfile b/.docker/images/httpd/Dockerfile new file mode 100644 index 000000000..aab8bc21c --- /dev/null +++ b/.docker/images/httpd/Dockerfile @@ -0,0 +1,3 @@ +FROM httpd +RUN apt-get update && apt-get install -y --no-install-recommends nano less bash libapache2-mod-xsendfile +RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* diff --git a/.docker/images/php/Dockerfile b/.docker/images/php/Dockerfile new file mode 100644 index 000000000..84b58c3e9 --- /dev/null +++ b/.docker/images/php/Dockerfile @@ -0,0 +1,95 @@ +############################################ +# PHPDocker.io PHP 8.1 / CLI and FPM image # +############################################ + +FROM ubuntu:jammy AS cli + +WORKDIR "/application" + +# Fixes some weird terminal issues such as broken clear / CTRL+L +ENV TERM=linux + +# Ensure apt doesn't ask questions when installing stuff +ENV DEBIAN_FRONTEND=noninteractive + +# Install Ondrej repos for Ubuntu jammy, PHP, composer and selected extensions - better selection than +# the distro's packages +RUN apt-get update && apt-get install -y --no-install-recommends gnupg \ + && echo "deb http://ppa.launchpad.net/ondrej/php/ubuntu jammy main" > /etc/apt/sources.list.d/ondrej-php.list \ + && apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4F4EA0AAE5267A6C \ + && apt-get update \ + && apt-get -y --no-install-recommends install \ + ca-certificates \ + curl \ + unzip \ + git \ + php8.1-apcu \ + php8.1-cli \ + php8.1-curl \ + php8.1-mbstring \ + php8.1-opcache \ + php8.1-readline \ + php8.1-xml \ + php8.1-zip \ + php8.1-bz2 \ + php8.1-gd \ + php8.1-igbinary \ + php8.1-imap \ + php8.1-imagick \ + php8.1-intl \ + php8.1-memcached \ + php8.1-mysql \ + php8.1-redis \ + php8.1-soap \ + php8.1-ssh2 \ + php8.1-tidy \ + php8.1-xsl \ + php8.1-curl \ + php8.1-mcrypt \ + less nano wget bash lynx + +COPY --from=composer:2 /usr/bin/composer /usr/bin/composer + +CMD ["php", "-a"] + +# If you'd like to be able to use this container on a docker-compose environment as a quiescent PHP CLI container +# you can /bin/bash into, override CMD with the following - bear in mind that this will make docker-compose stop +# slow on such a container, docker-compose kill might do if you're in a hurry +# CMD ["tail", "-f", "/dev/null"] + +FROM cli AS fpm + +# Install FPM +RUN apt-get update \ + && apt-get -y --no-install-recommends install php8.1-fpm + +STOPSIGNAL SIGQUIT + +# Toolbox +RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash - && apt-get install -y nodejs + +RUN apt-get -y --no-install-recommends install sudo +RUN apt-get -y --no-install-recommends install supervisor ssh rsync +RUN apt-get -y --no-install-recommends install nsis +RUN apt-get -y --no-install-recommends install default-jre pdftk poppler-utils ghostscript imagemagick netpbm libjpeg-turbo8 +RUN apt-get -y --no-install-recommends install zip unzip gzip 7zip +RUN apt-get -y --no-install-recommends install icoutils fontforge +RUN apt-get -y --no-install-recommends install ffmpeg python3 +RUN apt-get -y --no-install-recommends install inkscape mupdf-tools +RUN apt-get -y --no-install-recommends install cron + +RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* +RUN curl -L https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp -o /usr/local/bin/yt-dlp && chmod a+rx /usr/local/bin/yt-dlp && ln -s /usr/local/bin/yt-dlp /usr/local/bin/youtube-dl + +RUN useradd -d /application -g www-data -s /bin/bash -u 1001 toolbox +RUN npm install --unsafe-perm --global uglify-js less puppeteer + +# PHP-FPM packages need a nudge to make them docker-friendly +COPY overrides.conf /etc/php/8.1/fpm/pool.d/z-overrides.conf + +#CMD ["/usr/sbin/php-fpm8.1", "-O" ] +COPY startup /usr/bin/startup +CMD exec /usr/bin/startup + +# Open up fcgi port +EXPOSE 9000 diff --git a/.docker/images/php/overrides.conf b/.docker/images/php/overrides.conf new file mode 100644 index 000000000..5d60f05fb --- /dev/null +++ b/.docker/images/php/overrides.conf @@ -0,0 +1,37 @@ +[global] +; Override default pid file +pid = /run/php-fpm.pid + +; Avoid logs being sent to syslog +error_log = /proc/self/fd/2 + +; Set this to php default's max_execution_time to allow children to stop gracefully when fpm is commanded to stop +; This helps avoiding 502's +process_control_timeout = 30 + +; Do not daemonize (eg send process to the background) +daemonize = no + +[www] +; Access from webserver container is via network, not socket file +listen = [::]:9000 + +; Redirect logs to stdout - FPM closes /dev/std* on startup +access.log = /proc/self/fd/2 +catch_workers_output = yes + +; Remove "pool www" decoration from log output (older phpdocker.io containers for php use sed for this) +decorate_workers_output = no + +; Required to allow config-by-environment +clear_env = no + +user = 1001 +group = 33 + +pm = dynamic +pm.max_children = 80 +pm.start_servers = 24 +pm.min_spare_servers = 20 +pm.max_spare_servers = 40 +pm.max_requests = 1000 diff --git a/.docker/images/php/startup b/.docker/images/php/startup new file mode 100644 index 000000000..d2ec45531 --- /dev/null +++ b/.docker/images/php/startup @@ -0,0 +1,6 @@ +#!/bin/sh + +chmod 0644 /etc/crontab && crontab -u root /etc/crontab +/usr/sbin/service cron start +/usr/sbin/service supervisor start +/usr/sbin/php-fpm8.1 -O diff --git a/app/Jobs/FluidbookCompiler.php b/app/Jobs/FluidbookCompiler.php index 0fb18c0ae..ed2fe184a 100644 --- a/app/Jobs/FluidbookCompiler.php +++ b/app/Jobs/FluidbookCompiler.php @@ -1072,7 +1072,7 @@ class FluidbookCompiler extends Base implements CompilerInterface { $currenttime = microtime(true); if (null === $this->logfp) { - $this->logfp = fopen('/var/log/extranet/htmlconversions/' . $this->book_id . '.log', 'w+'); + $this->logfp = fopen(Files::mkdir(storage_path('logs/htmlconversions')) . $this->book_id . '.log', 'w+'); } if (null === $this->logtime) { $this->logtime = $currenttime;