From 9e0203c6b7a9e0bdc9519eea2fb195f274aa47a8 Mon Sep 17 00:00:00 2001 From: Alexandre BRACH Date: Mon, 13 May 2019 11:06:03 +0200 Subject: [PATCH 1/6] Multistage build --- Dockerfile | 150 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 150 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000..601a2aef9f --- /dev/null +++ b/Dockerfile @@ -0,0 +1,150 @@ +FROM php:7.1-fpm-stretch as builder + +RUN apt-get update \ + && apt-get install -y \ + apt-transport-https \ + ca-certificates \ + gnupg2 \ + && apt-get update \ + && apt-get install -y --no-install-recommends zlib1g-dev \ + git \ + ghostscript \ + gpac \ + imagemagick \ + libav-tools \ + libfreetype6-dev \ + libicu-dev \ + libjpeg62-turbo-dev \ + libmagickwand-dev \ + libmcrypt-dev \ + libpng-dev \ + librabbitmq-dev \ + libssl-dev \ + libxslt-dev \ + libzmq3-dev \ + locales \ + mcrypt \ + supervisor \ + swftools \ + unoconv \ + unzip \ + xpdf \ + && update-locale "LANG=fr_FR.UTF-8 UTF-8" \ + && dpkg-reconfigure --frontend noninteractive locales \ + && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \ + && docker-php-ext-install -j$(nproc) gd \ + && docker-php-ext-install zip exif iconv mbstring pcntl sockets xsl intl pdo_mysql gettext bcmath mcrypt \ + && pecl install redis amqp-1.9.3 zmq-beta imagick-beta \ + && docker-php-ext-enable redis amqp zmq imagick \ + && pecl clear-cache \ + && docker-php-source delete \ + && rm -rf /var/lib/apt/lists/* \ + && mkdir -p /var/log/supervisor + #&& chown -R app: /var/log/supervisor + +RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \ + && php -r "if (hash_file('sha384', 'composer-setup.php') === '48e3236262b34d30969dca3c37281b3b4bbe3221bda826ac6a9a62d6444cdb0dcd0615698a5cbe587c3f0fe57a54d8f5') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" \ + && php composer-setup.php --install-dir=/usr/local/bin --filename=composer \ + && php -r "unlink('composer-setup.php');" + +# Node Installation (node + yarn) +# Reference : +# https://linuxize.com/post/how-to-install-node-js-on-ubuntu-18.04/ +# https://yarnpkg.com/lang/en/docs/install/#debian-stable +RUN curl -sL https://deb.nodesource.com/setup_10.x | bash - \ + && apt install nodejs \ + && curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \ + && echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list \ + && apt-get update && apt-get install -y --no-install-recommends yarn \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/ + +RUN mkdir /entrypoint /var/alchemy \ + && useradd -u 1000 app \ + && mkdir -p /home/app/.composer \ + && chown -R app: /home/app /var/alchemy + + +ADD ./docker/phraseanet/ / + +WORKDIR /var/alchemy/ + +COPY config /var/alchemy/config +COPY grammar /var/alchemy/grammar +COPY lib /var/alchemy/lib +COPY resources /var/alchemy/resources +COPY templates-profiler /var/alchemy/templates-profiler +COPY templates /var/alchemy/templates +COPY tests /var/alchemy/tests +COPY tmp /var/alchemy/tmp +COPY www /var/alchemy/www +COPY composer.json /var/alchemy/ +COPY composer.lock /var/alchemy/ +COPY gulpfile.js /var/alchemy/ +COPY Makefile /var/alchemy/ +COPY package.json /var/alchemy/ +COPY phpunit.xml.dist /var/alchemy/ +COPY yarn.lock /var/alchemy/ + +RUN make install_composer +RUN make clean_assets +RUN make install_asset_dependencies +RUN make install_assets + +FROM php:7.1-fpm-stretch as phraseanet + +RUN apt-get update \ + && apt-get install -y \ + apt-transport-https \ + ca-certificates \ + gnupg2 \ + && apt-get update \ + && apt-get install -y --no-install-recommends zlib1g-dev \ + git \ + ghostscript \ + gpac \ + imagemagick \ + libav-tools \ + libfreetype6-dev \ + libicu-dev \ + libjpeg62-turbo-dev \ + libmagickwand-dev \ + libmcrypt-dev \ + libpng-dev \ + librabbitmq-dev \ + libssl-dev \ + libxslt-dev \ + libzmq3-dev \ + locales \ + mcrypt \ + supervisor \ + swftools \ + unoconv \ + unzip \ + xpdf \ + && update-locale "LANG=fr_FR.UTF-8 UTF-8" \ + && dpkg-reconfigure --frontend noninteractive locales \ + && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \ + && docker-php-ext-install -j$(nproc) gd \ + && docker-php-ext-install zip exif iconv mbstring pcntl sockets xsl intl pdo_mysql gettext bcmath mcrypt \ + && pecl install redis amqp-1.9.3 zmq-beta imagick-beta \ + && docker-php-ext-enable redis amqp zmq imagick \ + && pecl clear-cache \ + && docker-php-source delete \ + && rm -rf /var/lib/apt/lists/* \ + && mkdir -p /var/log/supervisor + +RUN mkdir -p /var/alchemy/logs && chmod 777 /var/alchemy/logs \ + && mkdir -p /var/alchemy/cache && chmod 777 /var/alchemy/cache +COPY --from=builder [^(www)] /var/alchemy /var/alchemy + +CMD ["php-fpm"] + +FROM nginx:1.15 as phraseanet-nginx + +RUN useradd -u 1000 app + +ADD ./docker/nginx/ / + +COPY --from=builder /var/alchemy/www /var/alchemy/Phraseanet/www + From f09c991b3f379d0419301c419b0f4da4fbeb2c2a Mon Sep 17 00:00:00 2001 From: Nicolas Maillat Date: Mon, 13 May 2019 14:38:15 +0200 Subject: [PATCH 2/6] Update Dockerfile --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index 5d993b4a8d..faddad5734 100644 --- a/Dockerfile +++ b/Dockerfile @@ -149,3 +149,4 @@ ADD ./docker/nginx/ / COPY --from=builder /var/alchemy/www /var/alchemy/Phraseanet/www + From 0d0e5e638863a18b8ba78222dbc77dd9a94ed9cc Mon Sep 17 00:00:00 2001 From: Jean-Yves Gaulier Date: Wed, 15 May 2019 11:50:27 +0200 Subject: [PATCH 3/6] PHRAS-2399_arch-task-cnx-timeout_4.1 add reconnect everywhere --- .../Phrasea/TaskManager/Job/ArchiveJob.php | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/lib/Alchemy/Phrasea/TaskManager/Job/ArchiveJob.php b/lib/Alchemy/Phrasea/TaskManager/Job/ArchiveJob.php index deaeb96ecc..532eb8bbb5 100644 --- a/lib/Alchemy/Phrasea/TaskManager/Job/ArchiveJob.php +++ b/lib/Alchemy/Phrasea/TaskManager/Job/ArchiveJob.php @@ -70,6 +70,10 @@ class ArchiveJob extends AbstractJob protected function doJob(JobData $data) { $app = $data->getApplication(); + + // quick fix to reconnect if mysql is lost + $app->getApplicationBox()->get_connection(); + $task = $data->getTask(); $settings = simplexml_load_string($task->getSettings()); @@ -83,6 +87,9 @@ class ArchiveJob extends AbstractJob $databox = $app->findDataboxById($sbasId); + // quick fix to reconnect if mysql is lost + $databox->get_connection(); + $TColls = []; $collection = null; foreach ($databox->get_collections() as $coll) { @@ -562,6 +569,10 @@ class ArchiveJob extends AbstractJob private function archive(Application $app, \databox $databox, \DOMDOcument $dom, \DOMElement $node, $path, $path_archived, $path_error, $depth, $moveError, $moveArchived, $stat0, $stat1) { + // quick fix to reconnect if mysql is lost + $app->getApplicationBox()->get_connection(); + $databox->get_connection(); + if ($node->getAttribute('temperature') == 'hot') { return; } @@ -820,6 +831,10 @@ class ArchiveJob extends AbstractJob private function archiveGrp(Application $app, \databox $databox, \DOMDocument $dom, \DOMElement $node, $path, $path_archived, $path_error, array &$nodesToDel, $moveError, $moveArchived, $stat0, $stat1) { + // quick fix to reconnect if mysql is lost + $app->getApplicationBox()->get_connection(); + $databox->get_connection(); + $xpath = new \DOMXPath($dom); // grp folders stay in place @@ -984,6 +999,10 @@ class ArchiveJob extends AbstractJob public function createStory(Application $app, \collection $collection, $pathfile, $captionFile, $stat0, $stat1) { + // quick fix to reconnect if mysql is lost + $app->getApplicationBox()->get_connection(); + $databox->get_connection(); + $status = \databox_status::operation_or($stat0, $stat1); $media = $app->getMediaFromUri($pathfile); @@ -1032,6 +1051,10 @@ class ArchiveJob extends AbstractJob */ public function createRecord(Application $app, \collection $collection, $pathfile, $captionFile, $grp_rid, $force, $stat0, $stat1) { + // quick fix to reconnect if mysql is lost + $app->getApplicationBox()->get_connection(); + $collection->get_connection(); + $status = \databox_status::operation_or($stat0, $stat1); $media = $app->getMediaFromUri($pathfile); @@ -1097,6 +1120,10 @@ class ArchiveJob extends AbstractJob */ private function archiveFilesToGrp(Application $app, \databox $databox, \DOMDocument $dom, \DOMElement $node, $path, $path_archived, $path_error, $grp_rid, $stat0, $stat1, $moveError, $moveArchived) { + // quick fix to reconnect if mysql is lost + $app->getApplicationBox()->get_connection(); + $databox->get_connection(); + $nodesToDel = []; for ($n = $node->firstChild; $n; $n = $n->nextSibling) { if (!$this->isStarted()) { @@ -1134,6 +1161,10 @@ class ArchiveJob extends AbstractJob */ private function archiveFile(Application $app, \databox $databox, \DOMDocument $dom, \DOMElement $node, $path, $path_archived, $path_error, array &$nodesToDel, $grp_rid, $stat0, $stat1, $moveError, $moveArchived) { + // quick fix to reconnect if mysql is lost + $app->getApplicationBox()->get_connection(); + $databox->get_connection(); + $match = $node->getAttribute('match'); if ($match == '*') { @@ -1188,6 +1219,10 @@ class ArchiveJob extends AbstractJob */ private function archiveFileAndCaption(Application $app, \databox $databox, \DOMDocument $dom, \DOMElement $node, \DOMElement $captionFileNode = null, $path, $path_archived, $path_error, $grp_rid, array &$nodesToDel, $stat0, $stat1, $moveError, $moveArchived) { + // quick fix to reconnect if mysql is lost + $app->getApplicationBox()->get_connection(); + $databox->get_connection(); + $file = $node->getAttribute('name'); $cid = $node->getAttribute('cid'); $captionFileName = $captionFileNode ? $captionFileNode->getAttribute('name') : null; @@ -1361,6 +1396,9 @@ class ArchiveJob extends AbstractJob */ protected function getLazaretSession(Application $app) { + // quick fix to reconnect if mysql is lost + $app->getApplicationBox()->get_connection(); + $lazaretSession = new LazaretSession(); $app['orm.em']->persist($lazaretSession); From 4097e19abbf17b6e4fa82af9f8bb1b5d23c48208 Mon Sep 17 00:00:00 2001 From: aina-esokia Date: Wed, 15 May 2019 16:13:16 +0400 Subject: [PATCH 4/6] add a video start t parameter in permalink url #time 6h --- lib/Alchemy/Phrasea/Controller/PermalinkController.php | 5 +++-- templates/web/overview.html.twig | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/Alchemy/Phrasea/Controller/PermalinkController.php b/lib/Alchemy/Phrasea/Controller/PermalinkController.php index 9baf7931bc..5f150c8a4a 100644 --- a/lib/Alchemy/Phrasea/Controller/PermalinkController.php +++ b/lib/Alchemy/Phrasea/Controller/PermalinkController.php @@ -74,10 +74,10 @@ class PermalinkController extends AbstractDelivery public function deliverPermaview(Request $request, $sbas_id, $record_id, $subdef) { - return $this->doDeliverPermaview($sbas_id, $record_id, $request->query->get('token'), $subdef); + return $this->doDeliverPermaview($sbas_id, $record_id, $request->query->get('token'), $subdef, $request->query->get('t')); } - private function doDeliverPermaview($sbas_id, $record_id, $token, $subdefName) + private function doDeliverPermaview($sbas_id, $record_id, $token, $subdefName, $currentTime = null) { $databox = $this->findDataboxById($sbas_id); $record = $this->retrieveRecord($databox, $token, $record_id, $subdefName); @@ -105,6 +105,7 @@ class PermalinkController extends AbstractDelivery 'token' => $token, 'record' => $record, 'recordUrl' => $information->getUrl(), + 'currentTime' => $currentTime ]); } diff --git a/templates/web/overview.html.twig b/templates/web/overview.html.twig index 8f8fd83bee..2643b530e8 100644 --- a/templates/web/overview.html.twig +++ b/templates/web/overview.html.twig @@ -36,7 +36,7 @@ lang: "{{ app.locale }}", baseUrl: '{{ app['request'].getUriForPath('/') }}', basePath: '{{ app.request.basePath|e('js') }}', - recordUrl: '{{ url('alchemy_embed_view', {url: recordUrl|trim, autoplay: autoplay|default('false') }) }}', + recordUrl: '{{ url('alchemy_embed_view', {url: recordUrl|trim, autoplay: autoplay|default('false'), t: currentTime|trim }) | e('js')}}', debug: {% if app.debug == true %}true{% else %}false{% endif %} }); From 02790561b6124d9704753249933a195de7b6a0b1 Mon Sep 17 00:00:00 2001 From: Xavier Rousset Date: Wed, 15 May 2019 17:22:11 +0200 Subject: [PATCH 5/6] Update playbook for phraseanet vagrant box workflow --- Vagrantfile | 5 +++++ resources/ansible/playbook.yml | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Vagrantfile b/Vagrantfile index 1b1f577b3f..74f8710e8e 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -123,6 +123,11 @@ Vagrant.configure("2") do |config| config.vm.box = "alchemy/Phraseanet-vagrant-dev" #config.vm.box = "ubuntu/trusty64" + # In case, Phraseanet box, choose the php version + # For php 7.0 use box 0.0.1 + # For php 7.1 use box 0.0.2 + config.vm.box_version = "0.0.1" + config.ssh.forward_agent = true config_net(config) diff --git a/resources/ansible/playbook.yml b/resources/ansible/playbook.yml index 704c5b96ec..370b427481 100644 --- a/resources/ansible/playbook.yml +++ b/resources/ansible/playbook.yml @@ -7,12 +7,12 @@ # - server # - repositories # - vagrant_local -# - nginx + - nginx # - mariadb # - elasticsearch # - rabbitmq # - php -# - xdebug + - xdebug # - composer # - mailcatcher # - node From f5af760e866af29fa62a2c7b1ef217b23bed5f1b Mon Sep 17 00:00:00 2001 From: Nicolas Maillat Date: Thu, 16 May 2019 10:55:35 +0200 Subject: [PATCH 6/6] Remove artefact --- Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index faddad5734..c0ea67e61b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -74,7 +74,6 @@ COPY config /var/alchemy/config COPY grammar /var/alchemy/grammar COPY lib /var/alchemy/lib COPY resources /var/alchemy/resources -RUN ls -la COPY templates-profiler /var/alchemy/templates-profiler COPY templates /var/alchemy/templates COPY tests /var/alchemy/tests