From 794f9900af78eb0da94453edb6167f35ae354c17 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Wed, 5 Oct 2022 11:50:44 +0200 Subject: [PATCH] wip #5506 @9 --- .gitignore | 2 +- .ssh/authorized_keys | 1 - Dockerfile | 19 +++++++++++ README.md | 6 +--- app/bin/mount | 7 ++++ composer.json => app/composer.json | 0 app/info.php | 2 ++ app/ping.php | 2 ++ app/process.php | 8 +++++ src/Process.php => app/src/ProcessFile.php | 5 ++- bin/fixrights | 7 ---- bin/install | 7 ---- bin/installpackages | 12 ------- bin/mount | 9 ------ bin/ping | 8 ----- bin/process | 3 -- bin/process.php | 9 ------ bin/update | 9 ------ docker-compose.yml | 16 ++++++++++ etc/sudoers | 1 - overrides.conf | 37 ++++++++++++++++++++++ {.ssh => ssh}/id_rsa | 0 {.ssh => ssh}/id_rsa.pub | 0 {.ssh => ssh}/known_hosts | 0 startup | 3 ++ update | 13 ++++++++ 26 files changed, 111 insertions(+), 75 deletions(-) delete mode 100644 .ssh/authorized_keys create mode 100644 Dockerfile create mode 100755 app/bin/mount rename composer.json => app/composer.json (100%) create mode 100644 app/info.php create mode 100644 app/ping.php create mode 100644 app/process.php rename src/Process.php => app/src/ProcessFile.php (94%) delete mode 100755 bin/fixrights delete mode 100755 bin/install delete mode 100755 bin/installpackages delete mode 100644 bin/mount delete mode 100644 bin/ping delete mode 100644 bin/process delete mode 100644 bin/process.php delete mode 100755 bin/update create mode 100644 docker-compose.yml delete mode 100644 etc/sudoers create mode 100644 overrides.conf rename {.ssh => ssh}/id_rsa (100%) rename {.ssh => ssh}/id_rsa.pub (100%) rename {.ssh => ssh}/known_hosts (100%) create mode 100755 startup create mode 100755 update diff --git a/.gitignore b/.gitignore index f485327..ad2b13e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ ### Laravel template -/vendor/ +/app/vendor/ node_modules/ npm-debug.log yarn-error.log diff --git a/.ssh/authorized_keys b/.ssh/authorized_keys deleted file mode 100644 index 2330a97..0000000 --- a/.ssh/authorized_keys +++ /dev/null @@ -1 +0,0 @@ -ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC3vHNE7na68aUPFwAK4h3VW+PR4GZaLsTCdySLdt8974jKltMDfWdEbM//mQOm4nOLDkPkbn+TX0GuTNu/SnFTP/qnG7e+p+pqhuYrvw9CHBHtsGoPZS1ZWs53wuXbuJmYTzJMaMV+dibRh2rX/uzH7dBNVQJMGFcQkjrq/UnhJTgKZPprhx2tDV4Rm72GXH4JOi+yautM7jK21gpxdFUJy7VaNaPB1iqcCikn+htCNs1n8BjVRwAMPI9AB6eEgfX68DyVF80TGLyWxlCumFOZXDELhOneJtO0zFMSEuBVXbPm2fNq1jaMaeqgmZqQiZNM0o4hqW/ZLcRH0k+gGXHH extranet@amarcord.cubedesigners.com \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d317418 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,19 @@ +FROM ubuntu:jammy +WORKDIR "/application" + +ENV TERM=linux +ENV DEBIAN_FRONTEND=noninteractive + +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 x11-common pdftk poppler-utils ghostscript netpbm sshfs mupdf-tools php8.1-cli php8.1-fpm php8.1-curl php8.1-exif php8.1-xml php8.1-gd php8.1-ssh php8.1-zip libjpeg-turbo-progs zip unzip \ + less nano wget bash lynx + +COPY --from=composer:2 /usr/bin/composer /usr/bin/composer +COPY overrides.conf /etc/php/8.1/fpm/pool.d/z-overrides.conf +COPY --chmod=755 startup /usr/bin/startup +CMD exec /usr/bin/startup +STOPSIGNAL SIGQUIT +EXPOSE 9000 diff --git a/README.md b/README.md index a2873cd..68321e8 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,4 @@ On the farming server : -`apt install -y git;cd /usr/local/;git clone git://git.cubedesigners.com/fluidbook_processfarm.git;/usr/local/fluidbook_processfarm/bin/install` - -On the alien server (logged in as extranet), connect once on the new farming server to add it to known host - -`ssh -p 22 fluidbookfarmer@host.cubedesigners.com` \ No newline at end of file +`apt install -y git;mkdir -p /docker/fluidbook-processfarm;git clone git://git.cubedesigners.com/fluidbook_processfarm.git .;./update` \ No newline at end of file diff --git a/app/bin/mount b/app/bin/mount new file mode 100755 index 0000000..a2da5dc --- /dev/null +++ b/app/bin/mount @@ -0,0 +1,7 @@ +#!/bin/bash +mkdir -p /files +if mountpoint -q "/files"; then + : +else + sshfs -o reconnect,ServerAliveInterval=15,ServerAliveCountMax=3 -o uid=33 -o gid=33 -o allow_other root@godzilla.cubedesigners.com:/data/fluidbook/docs /files +fi \ No newline at end of file diff --git a/composer.json b/app/composer.json similarity index 100% rename from composer.json rename to app/composer.json diff --git a/app/info.php b/app/info.php new file mode 100644 index 0000000..bfd863b --- /dev/null +++ b/app/info.php @@ -0,0 +1,2 @@ +process()); \ No newline at end of file diff --git a/src/Process.php b/app/src/ProcessFile.php similarity index 94% rename from src/Process.php rename to app/src/ProcessFile.php index 21f13f0..076b9fa 100644 --- a/src/Process.php +++ b/app/src/ProcessFile.php @@ -4,12 +4,11 @@ namespace Fluidbook\Farmer; use Cubist\PDF\PDFTools; use Cubist\Util\Files\Files; -use Fluidbook\Tools\Jobs\ProcessFile; -class Process extends ProcessFile +class ProcessFile extends \Fluidbook\Tools\Jobs\ProcessFile { protected const DISTANT_ROOT = '/data1/extranet/www/fluidbook/docs/'; - protected const LOCAL_ROOT = '/usr/local/fluidbook_processfarm/files/'; + protected const LOCAL_ROOT = '/files/'; protected $page; protected $out; diff --git a/bin/fixrights b/bin/fixrights deleted file mode 100755 index fc9165f..0000000 --- a/bin/fixrights +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh -chown -R fluidbookfarmer:fluidbookfarmer /usr/local/fluidbook_processfarm/* -chown -R fluidbookfarmer:fluidbookfarmer /usr/local/fluidbook_processfarm/.ssh -chmod 755 /usr/local/fluidbook_processfarm/bin/* -chmod 755 /usr/local/fluidbook_processfarm/.ssh -chmod 600 /usr/local/fluidbook_processfarm/.ssh/id_rsa -chmod 644 /usr/local/fluidbook_processfarm/.ssh/authorized_keys \ No newline at end of file diff --git a/bin/install b/bin/install deleted file mode 100755 index e91fa6e..0000000 --- a/bin/install +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh -chmod 755 /usr/local/fluidbook_processfarm/bin/* -groupadd fluidbookfarmer || true -useradd fluidbookfarmer -g fluidbookfarmer --home /usr/local/fluidbook_processfarm -s /bin/bash || true -mkdir -p /usr/local/fluidbook_processfarm/files -/usr/local/fluidbook_processfarm/bin/update -cp /usr/local/fluidbook_processfarm/etc/sudoers /etc/sudoers.d/fluidbook_processfarm \ No newline at end of file diff --git a/bin/installpackages b/bin/installpackages deleted file mode 100755 index 7bc7b6a..0000000 --- a/bin/installpackages +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh -add-apt-repository -y ppa:ondrej/php -#apt-get update -apt-get install -y x11-common pdftk poppler-utils ghostscript netpbm sshfs mupdf-tools php8.1 php8.1-curl php8.1-exif php8.1-xml php8.1-gd php8.1-ssh php8.1-zip libjpeg-turbo-progs zip unzip - -if [ ! -f /usr/local/bin/composer ] -then - php -r "copy('https://getcomposer.org/installer', '/tmp/composer-setup.php');" - php /tmp/composer-setup.php - php -r "unlink('/tmp/composer-setup.php');" - mv composer.phar /usr/local/bin/composer -fi diff --git a/bin/mount b/bin/mount deleted file mode 100644 index b2a6c71..0000000 --- a/bin/mount +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh -if mountpoint -q "/usr/local/fluidbook_processfarm/files"; then - echo "" -else - sshfs -o uid=`id -u fluidbookfarmer` -o gid=`id -g fluidbookfarmer` root@godzilla.cubedesigners.com:/data/fluidbook/docs /usr/local/fluidbook_processfarm/files -fi - - - diff --git a/bin/ping b/bin/ping deleted file mode 100644 index d4cc2e1..0000000 --- a/bin/ping +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -/usr/local/fluidbook_processfarm/bin/mount > /dev/null 2>&1 -FILE=/usr/local/fluidbook_processfarm/files/status -if [ -f "$FILE" ]; then - echo "1" -else - echo "0" -fi diff --git a/bin/process b/bin/process deleted file mode 100644 index 08773fb..0000000 --- a/bin/process +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -/usr/local/fluidbook_processfarm/bin/mount -/usr/bin/php8.1 -f /usr/local/fluidbook_processfarm/bin/process.php -- $1 \ No newline at end of file diff --git a/bin/process.php b/bin/process.php deleted file mode 100644 index 879e2cf..0000000 --- a/bin/process.php +++ /dev/null @@ -1,9 +0,0 @@ -process(); \ No newline at end of file diff --git a/bin/update b/bin/update deleted file mode 100755 index adee59f..0000000 --- a/bin/update +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh -cd /usr/local/fluidbook_processfarm -git config --global --add safe.directory /usr/local/fluidbook_processfarm -git stash -git pull origin master -chmod 755 /usr/local/fluidbook_processfarm/bin/* -/usr/local/fluidbook_processfarm/bin/installpackages -/usr/local/fluidbook_processfarm/bin/fixrights -export COMPOSER_ALLOW_SUPERUSER=1;composer update \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..6abc8e6 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,16 @@ +version: '3.1' +services: + php: + container_name: fluidbook-processfarm + build: . + working_dir: /application + environment: + TZ: Europe/Paris + HOME: /application + volumes: + - './app/:/application/' + - './ssh/:/root/.ssh/' + ports: + - '9457:9000' + restart: unless-stopped + privileged: true \ No newline at end of file diff --git a/etc/sudoers b/etc/sudoers deleted file mode 100644 index 6a2f108..0000000 --- a/etc/sudoers +++ /dev/null @@ -1 +0,0 @@ -fluidbookfarmer ALL=(ALL) NOPASSWD: /usr/local/fluidbook_processfarm/bin/update diff --git a/overrides.conf b/overrides.conf new file mode 100644 index 0000000..37a1483 --- /dev/null +++ b/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/1 +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 = 33 +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/.ssh/id_rsa b/ssh/id_rsa similarity index 100% rename from .ssh/id_rsa rename to ssh/id_rsa diff --git a/.ssh/id_rsa.pub b/ssh/id_rsa.pub similarity index 100% rename from .ssh/id_rsa.pub rename to ssh/id_rsa.pub diff --git a/.ssh/known_hosts b/ssh/known_hosts similarity index 100% rename from .ssh/known_hosts rename to ssh/known_hosts diff --git a/startup b/startup new file mode 100755 index 0000000..93ca79a --- /dev/null +++ b/startup @@ -0,0 +1,3 @@ +#!/bin/sh +/application/bin/mount +/usr/sbin/php-fpm8.1 -O \ No newline at end of file diff --git a/update b/update new file mode 100755 index 0000000..677f763 --- /dev/null +++ b/update @@ -0,0 +1,13 @@ +#!/bin/bash +cd /docker/fluidbook-processfarm +git config --global --add safe.directory /docker/fluidbook-processfarm +git stash +git pull origin master +chmod 755 /docker/fluidbook-processfarm/app/bin/* +chmod 755 /docker/fluidbook-processfarm/ssh +chmod 600 /docker/fluidbook-processfarm/ssh/id_rsa +chmod 644 /docker/fluidbook-processfarm/ssh/authorized_keys +DOCKER_BUILDKIT=1 docker compose build +docker compose down +docker compose up -d +docker exec fluidbook-processfarm composer update \ No newline at end of file -- 2.39.5