Skip to content

Commit

Permalink
Merge branch 'master' into PHRAS-4038-prod-403-when-open-in-multi-tab
Browse files Browse the repository at this point in the history
  • Loading branch information
nmaillat authored Mar 19, 2024
2 parents 95538df + f1b8121 commit 3b0d73c
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 212 deletions.
221 changes: 15 additions & 206 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,206 +1,18 @@
#########################################################################
# This image contains every build tools that will be used by the builder and
# the app images (usefull in dev mode)
#########################################################################

FROM php:7.0-fpm-stretch as phraseanet-system

ENV FFMPEG_VERSION=4.2.2

RUN echo "deb http://archive.debian.org/debian stretch main non-free" > /etc/apt/sources.list \
&& apt-get update \
&& apt-get install -y \
apt-transport-https \
ca-certificates \
gnupg2 \
wget \
&& wget -O certs.deb http://ftp.fr.debian.org/debian/pool/main/c/ca-certificates/ca-certificates_20210119_all.deb \
&& dpkg --fsys-tarfile certs.deb | tar -xOf - ./usr/share/ca-certificates/mozilla/ISRG_Root_X1.crt > /usr/local/share/ca-certificates/ISRG_Root_X1.crt \
&& rm -rf /usr/share/ca-certificates/mozilla/DST_Root_CA_X3.crt \
&& update-ca-certificates --fresh \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
zlib1g-dev \
automake \
git \
ghostscript \
gpac \
imagemagick \
ufraw \
inkscape \
libav-tools \
libfreetype6-dev \
libicu-dev \
libjpeg62-turbo-dev \
libmagickwand-dev \
libmcrypt-dev \
libpng-dev \
librabbitmq-dev \
libssl-dev \
libxslt-dev \
libzmq3-dev \
libtool \
locales \
gettext \
mcrypt \
swftools \
unoconv \
unzip \
poppler-utils \
libreoffice-base-core \
libreoffice-impress \
libreoffice-calc \
libreoffice-math \
libreoffice-writer \
libreoffice-pdfimport \
# heic
libde265-dev \
libopenjp2-7-dev \
librsvg2-dev \
libwebp-dev \
# End heic
# FFmpeg
yasm \
libvorbis-dev \
texi2html \
nasm \
zlib1g-dev \
libx264-dev \
libfdk-aac-dev \
libopus-dev \
libvpx-dev \
libmp3lame-dev \
libogg-dev \
libopencore-amrnb-dev \
libopencore-amrwb-dev \
libdc1394-22-dev \
libx11-dev \
libswscale-dev \
libpostproc-dev \
libxvidcore-dev \
libtheora-dev \
libgsm1-dev \
libfreetype6-dev \
libldap2-dev \
# End FFmpeg \
nano \
&& update-locale "LANG=fr_FR.UTF-8 UTF-8" \
&& dpkg-reconfigure --frontend noninteractive locales \
# --- jq and libs for php-ext-jq \
&& mkdir /tmp/libjq \
&& git clone https://github.com/stedolan/jq.git /tmp/libjq \
&& cd /tmp/libjq \
&& git checkout fd9da6647c0fa619f03464fe37a4a10b70147e73 \
&& git submodule update --init \
&& autoreconf -fi \
&& ./configure --with-oniguruma=builtin --disable-maintainer-mode \
&& make -j8 \
&& make check \
&& make install \
# --- end of jq \
&& mkdir /tmp/libheif \
&& git clone https://github.com/strukturag/libheif.git /tmp/libheif \
&& cd /tmp/libheif \
&& git checkout v1.13.0 \
&& ./autogen.sh \
&& ./configure \
&& make \
&& make install
RUN echo "BUILDING AND INSTALLING IMAGEMAGICK" \
&& git clone https://github.com/ImageMagick/ImageMagick.git /tmp/ImageMagick \
&& cd /tmp/ImageMagick \
&& git checkout 7.1.0-39 \
&& ./configure \
&& make \
&& make install
RUN echo "BUILDING PHP PECL EXTENTIONS" \
&& ldconfig \
&& 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-configure ldap --with-libdir=lib/x86_64-linux-gnu/ \
&& docker-php-ext-install -j$(nproc) ldap \
&& docker-php-ext-install zip exif iconv mbstring pcntl sockets xsl intl pdo_mysql gettext bcmath mcrypt \
# --- extension jq - sources _must_ be in /usr/src/php/ext/ for the docker-php-ext-install script to find it \
&& mkdir -p /usr/src/php/ext/ \
&& git clone --depth=1 https://github.com/kjdev/php-ext-jq.git /usr/src/php/ext/php-ext-jq \
&& docker-php-ext-install php-ext-jq \
# --- end of extension jq \
&& pecl install \
redis-5.3.7 \
amqp-1.9.3 \
zmq-beta \
imagick-beta \
xdebug-2.6.1 \
&& docker-php-ext-enable redis amqp zmq imagick opcache \
&& pecl clear-cache \
&& docker-php-source delete
RUN echo "BUILDING AND INSTALLING FFMPEG" \
&& mkdir /tmp/ffmpeg \
&& curl -s https://ffmpeg.org/releases/ffmpeg-${FFMPEG_VERSION}.tar.bz2 | tar jxf - -C /tmp/ffmpeg \
&& ( \
cd /tmp/ffmpeg/ffmpeg-${FFMPEG_VERSION} \
&& ./configure \
--enable-gpl \
--enable-nonfree \
--enable-libfdk-aac \
--enable-libfdk_aac \
--enable-libgsm \
--enable-libmp3lame \
--enable-libtheora \
--enable-libvorbis \
--enable-libvpx \
--enable-libfreetype \
--enable-libopus \
--enable-libx264 \
--enable-libxvid \
--enable-zlib \
--enable-postproc \
--enable-swscale \
--enable-pthreads \
--enable-libdc1394 \
--enable-version3 \
--enable-libopencore-amrnb \
--enable-libopencore-amrwb \
&& make \
&& make install \
&& make distclean \
)
#&& rm -rf /tmp/ffmpeg
RUN echo "INSTALLING NEWRELIC EXTENTION" \
&& echo 'deb http://apt.newrelic.com/debian/ newrelic non-free' | tee /etc/apt/sources.list.d/newrelic.list \
&& curl -o- https://download.newrelic.com/548C16BF.gpg | apt-key add - \
&& apt-get update \
&& apt-get install -y newrelic-php5 \
&& NR_INSTALL_SILENT=1 newrelic-install install \
&& touch /etc/newrelic/newrelic.cfg
RUN echo "FINALIZING BUILD AND CLEANING" \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists \
&& mkdir /entrypoint /var/alchemy \
&& useradd -u 1000 app \
&& mkdir -p /home/app/.composer \
&& chown -R app: /home/app /var/alchemy

ENV XDEBUG_ENABLED=0

#########################################################################
# This image is used to build the apps
#########################################################################

FROM phraseanet-system as builder
FROM alchemyfr/phraseanet-base:1.0.0 as builder

COPY --from=composer:2.1.6 /usr/bin/composer /usr/bin/composer

# 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 - \

RUN cd /tmp \
&& curl -O https://nodejs.org/download/release/v10.24.1/node-v10.24.1-linux-x64.tar.gz \
&& tar -xvf node-v10.24.1-linux-x64.tar.gz \
&& cp -Rf node-v10.24.1-linux-x64/* /usr/ \
&& 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 \
nodejs \
yarn \
nano \
vim \
Expand All @@ -210,7 +22,7 @@ RUN curl -sL https://deb.nodesource.com/setup_10.x | bash - \
telnet \
autoconf \
libtool \
python \
python3 \
pkg-config \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists \
Expand Down Expand Up @@ -250,7 +62,7 @@ RUN ( \
&& chmod 600 ~/.ssh/id_rsa \
) || echo "Skip SSH key"

RUN ./docker/phraseanet/plugins/console install
# RUN ./docker/phraseanet/plugins/console install

ENTRYPOINT ["/bootstrap/entrypoint.sh"]

Expand All @@ -260,7 +72,7 @@ CMD []
# Phraseanet install and setup application image
#########################################################################

FROM phraseanet-system as phraseanet-setup
FROM alchemyfr/phraseanet-base:1.0.0 as phraseanet-setup

COPY --from=builder --chown=app /var/alchemy/Phraseanet /var/alchemy/Phraseanet
ADD ./docker/phraseanet/root /
Expand All @@ -273,7 +85,7 @@ CMD []
# Phraseanet web application image
#########################################################################

FROM phraseanet-system as phraseanet-fpm
FROM alchemyfr/phraseanet-base:1.0.0 as phraseanet-fpm

COPY --from=builder --chown=app /var/alchemy/Phraseanet /var/alchemy/Phraseanet
ADD ./docker/phraseanet/root /
Expand All @@ -286,11 +98,10 @@ CMD ["php-fpm", "-F"]
#########################################################################

FROM phraseanet-fpm as phraseanet-worker
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
supervisor \
logrotate \
&& mkdir -p /var/log/supervisor \
RUN apt-get update
RUN apt-get install -y --no-install-recommends supervisor
RUN apt-get install -y --no-install-recommends logrotate
RUN mkdir -p /var/log/supervisor \
&& chown -R app: /var/log/supervisor \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists
Expand Down Expand Up @@ -323,7 +134,7 @@ HEALTHCHECK CMD wget --spider http://127.0.0.1/login || nginx -s reload || exit
# phraseanet adapted simplesaml service provider
#########################################################################

FROM php:7.0-fpm-stretch as phraseanet-saml-sp
FROM alchemyfr/phraseanet-base:1.0.0 as phraseanet-saml-sp
RUN adduser --uid 1000 --disabled-password app
RUN echo "deb http://archive.debian.org/debian stretch main non-free" > /etc/apt/sources.list \
&& apt-get update \
Expand All @@ -344,8 +155,6 @@ RUN echo "deb http://archive.debian.org/debian stretch main non-free" > /etc/apt
mcrypt \
libldap2-dev \
&& curl -Ls https://github.com/simplesamlphp/simplesamlphp/releases/download/simplesamlphp-1.10.0/simplesamlphp-1.10.0.tar.gz | tar xzvf - -C /var/www/ \
&& docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu/ \
&& docker-php-ext-install -j$(nproc) ldap \
&& docker-php-ext-install zip mbstring pdo_mysql gettext mcrypt \
&& pecl install \
redis-5.3.7 \
Expand Down
2 changes: 1 addition & 1 deletion docker/phraseanet/worker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ else

if [ ! -z "$PHRASEANET_CMD_MODE" ] && [ ${PHRASEANET_CMD_MODE} == "1" ] ; then
apt update
apt install screen
apt install screen -y
echo "Worker are in custom process mode"
fi

Expand Down
9 changes: 8 additions & 1 deletion lib/Alchemy/Phrasea/Core/Event/Record/RecordEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@
abstract class RecordEvent extends Event
{
private $record;
private $initiatorId;

public function __construct(RecordInterface $record)
public function __construct(RecordInterface $record, $initiatorId = null)
{
$this->record = $record;
$this->initiatorId = $initiatorId;
}

/**
Expand All @@ -29,4 +31,9 @@ public function getRecord()
{
return $this->record;
}

public function getInitiatorId()
{
return $this->initiatorId;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,43 @@ public function __construct(Application $application)

public function onRecordCreated(RecordEvent $event)
{
$this->createWebhookEvent($event, WebhookEvent::RECORD_CREATED);
$record = $this->convertToRecordAdapter($event->getRecord());

if ($record !== null) {
$permalinkUrl = '';

try {
$permalink = $record->get_subdef('document')->get_permalink();
if ($permalink != null) {
$permalinkUrl = $permalink->get_url()->__toString();
}
} catch (\Exception $e) {
// there is no subdef 'document'
} catch (\Throwable $e) {
}

$eventData = [
'databox_id' => $event->getRecord()->getDataboxId(),
'record_id' => $event->getRecord()->getRecordId(),
'collection_name' => $record->getCollection()->get_name(),
'base_id' => $record->getBaseId(),
'record_type' => $event->getRecord()->isStory() ? "story" : "record",
'media_type' => $record->getType(),
'type' => $record->getMimeType(),
'original_name' => $record->getOriginalName(),
'initiator_user_id' => $event->getInitiatorId(),
'permalink' => $permalinkUrl
];

$this->app['manipulator.webhook-event']->create(
WebhookEvent::RECORD_CREATED,
WebhookEvent::RECORD_TYPE,
$eventData,
[$event->getRecord()->getBaseId()]
);
} else {
$this->app['logger']->error("Record not found when wanting to create webhook data!");
}
}

public function onRecordEdit(RecordEdit $event)
Expand Down
Loading

0 comments on commit 3b0d73c

Please sign in to comment.