Add Docker
This commit is contained in:
parent
2d034531af
commit
5a89cdb205
6 changed files with 72 additions and 5 deletions
10
.docker/apache2/soshot.conf
Normal file
10
.docker/apache2/soshot.conf
Normal file
|
@ -0,0 +1,10 @@
|
|||
<VirtualHost *:80>
|
||||
ErrorLog ${APACHE_LOG_DIR}/error.log
|
||||
ServerName sohsot.local
|
||||
DocumentRoot /var/www/public/
|
||||
<Directory "/var/www/public/">
|
||||
Require all granted
|
||||
AllowOverride All
|
||||
Options -Indexes
|
||||
</Directory>
|
||||
</VirtualHost>
|
3
.docker/start.sh
Normal file
3
.docker/start.sh
Normal file
|
@ -0,0 +1,3 @@
|
|||
#/bin/bash
|
||||
cron
|
||||
/usr/sbin/apache2ctl -DFOREGROUND
|
5
DockerRun
Normal file
5
DockerRun
Normal file
|
@ -0,0 +1,5 @@
|
|||
docker run -v soshot_datas:/var/www/datas -v soshot_cache_img:/var/www/cache/img -e TZ=UTC -p 8080:80 --name soshot soshot/0.1.0
|
||||
|
||||
or
|
||||
|
||||
docker run -v soshot_datas:/var/www/datas soshot --name soshot soshot
|
40
Dockerfile
Normal file
40
Dockerfile
Normal file
|
@ -0,0 +1,40 @@
|
|||
FROM ubuntu/apache2
|
||||
|
||||
MAINTAINER Knah Tsaeb <knah-tsaeb_soshot@knah-tsaeb.org>
|
||||
|
||||
LABEL version="0.1.0"
|
||||
LABEL description="Apache 2 / PHP / SoShot"
|
||||
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
RUN apt-get -y update && apt-get install -y php php-gd php-json php-sqlite3 php-mbstring php-xml php-curl wget gnupg git composer php-imagick sudo cron imagemagick && apt-get clean && apt-get autoclean && apt-get autoremove
|
||||
|
||||
RUN wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb && apt -y install ./google-chrome-stable_current_amd64.deb && apt-get -y update && apt-get install -y google-chrome-stable && apt-get clean && rm google-chrome-stable_current_amd64.deb && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
RUN rm -r /var/www/ && mkdir /var/www/
|
||||
|
||||
WORKDIR /var/www/
|
||||
RUN git clone https://forge.leslibres.org/Knah-Tsaeb/Soshot.git --branch dev --single-branch --depth 1 .
|
||||
RUN composer install --no-dev && chown -R www-data:www-data /var/www/
|
||||
|
||||
COPY .docker/start.sh /usr/bin/start.sh
|
||||
RUN chmod +x /usr/bin/start.sh
|
||||
|
||||
WORKDIR /
|
||||
|
||||
COPY .docker/apache2/soshot.conf /etc/apache2/sites-available/soshot.conf
|
||||
RUN a2dissite 000-default.conf && a2ensite soshot.conf && a2enmod rewrite
|
||||
|
||||
RUN echo '*/4 * * * * www-data php /var/www/bin/thumbShoter.php' > /etc/cron.d/soshot && chmod 0644 /etc/cron.d/soshot && crontab /etc/cron.d/soshot
|
||||
|
||||
EXPOSE 80
|
||||
VOLUME soshot_datas
|
||||
|
||||
WORKDIR /var/www/
|
||||
|
||||
ENTRYPOINT "start.sh"
|
||||
|
||||
# Build image
|
||||
# docker build -t soshot:0.1.0 .
|
||||
# Run container
|
||||
# docker run -v soshot_datas:/var/www/datas -v soshot_cache_img:/var/www/cache/img -e TZ=UTC -p 8080:80 --name soshot soshot/0.1.0
|
|
@ -50,6 +50,7 @@ class MakeThumb {
|
|||
public function compute() {
|
||||
foreach ($this->demandes as $demande) {
|
||||
$this->db->setParams($demande);
|
||||
file_put_contents('/tmp/soshot_queue', $demande->hmac);
|
||||
|
||||
// todo verif permit type
|
||||
|
||||
|
@ -138,11 +139,11 @@ class MakeThumb {
|
|||
mkdir($dir);
|
||||
}
|
||||
|
||||
$page = $browser->createPage();
|
||||
$page->navigate($demande->url)->waitForNavigation(Page::DOM_CONTENT_LOADED, 15000);
|
||||
sleep(4);
|
||||
|
||||
try {
|
||||
$page = $browser->createPage();
|
||||
$page->navigate($demande->url)->waitForNavigation(Page::LOAD, 15000);
|
||||
sleep(4);
|
||||
|
||||
$page->screenshot([
|
||||
'captureBeyondViewport' => true,
|
||||
'clip' => $page->getFullPageClip(),
|
||||
|
@ -197,7 +198,8 @@ class MakeThumb {
|
|||
],
|
||||
'noSandbox' => true,
|
||||
]);
|
||||
|
||||
\file_put_contents($this->fileSocket, $browser->getSocketUri(), LOCK_EX);
|
||||
return $browser;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
7
bin/cleanChromeCache.sh
Normal file
7
bin/cleanChromeCache.sh
Normal file
|
@ -0,0 +1,7 @@
|
|||
#!/bin/bash
|
||||
|
||||
FILE=/var/www/cache/tmp/chrome-php-socket
|
||||
if [ ! -f "$FILE" ]; then
|
||||
cd /tmp/chrome_soshot
|
||||
rm -R Default
|
||||
fi
|
Loading…
Reference in a new issue