Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Based onto Alpine Docker image allows to reduce image size by 2.4 #375

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 34 additions & 26 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,37 +1,45 @@
FROM debian:stretch-slim
FROM alpine:3.10.1

MAINTAINER CYOSP <[email protected]>

RUN DEBIAN_FRONTEND=noninteractive apt update && apt upgrade -yq && apt install -yq \
--no-install-recommends \
ca-certificates \
zip \
git \
nginx \
php-fpm \
php-gd \
php-xml \
libgd-dev \
supervisor \
exiftran \
RUN apk upgrade \
&& apk add \
ca-certificates \
git \
zip \
nginx \
php7-session \
php7-fpm \
php7-gd \
php7-xml \
php7-simplexml \
php7-exif \
gd-dev \
supervisor \
fbida-exiftran \
&& git clone https://github.com/thibaud-rohmer/PhotoShow.git /var/www/PhotoShow \
&& apt remove -yq \
ca-certificates \
git \
&& apt autoremove -yq

RUN mkdir -p /opt/PhotoShow/Photos /opt/PhotoShow/generated && chown -R www-data:www-data /opt/PhotoShow/Photos /opt/PhotoShow/generated
&& apk del ca-certificates git

RUN sed -i -e 's/$config->photos_dir.\+/$config->photos_dir = "\/opt\/PhotoShow\/Photos";/' /var/www/PhotoShow/config.php
RUN sed -i -e 's/$config->ps_generated.\+/$config->ps_generated = "\/opt\/PhotoShow\/generated";/' /var/www/PhotoShow/config.php
RUN deluser xfs
RUN adduser -u 33 -D -S -G www-data www-data

RUN rm -f /etc/nginx/sites-enabled/default && echo "daemon off;" >> /etc/nginx/nginx.conf && mkdir -p /var/run/php
RUN echo "daemon off;" >> /etc/nginx/nginx.conf
RUN rm /etc/nginx/conf.d/default.conf
ADD nginx.conf /etc/nginx/conf.d/photoshow.conf
RUN mkdir -p /run/nginx /var/run/php

RUN sed -i -e 's/^.\+daemonize.\+$/daemonize = no/' /etc/php/7.0/fpm/php-fpm.conf
ADD fpm.conf /etc/php/7.0/fpm/pool.d/photoshow.conf
RUN sed -i -e 's/^.\+daemonize.\+$/daemonize = no/' /etc/php7/php-fpm.conf
RUN rm /etc/php7/php-fpm.d/www.conf
ADD fpm.conf /etc/php7/php-fpm.d/photoshow.conf

RUN mkdir -p /opt/PhotoShow/Photos /opt/PhotoShow/generated
RUN chown -R www-data:www-data /opt/PhotoShow/Photos /opt/PhotoShow/generated
RUN sed -i -e 's/$config->photos_dir.\+/$config->photos_dir = "\/opt\/PhotoShow\/Photos";/' /var/www/PhotoShow/config.php
RUN sed -i -e 's/$config->ps_generated.\+/$config->ps_generated = "\/opt\/PhotoShow\/generated";/' /var/www/PhotoShow/config.php

RUN sed -i -e 's/^\(\[supervisord\]\)$/\1\nnodaemon=true/' /etc/supervisor/supervisord.conf
ADD supervisor.conf /etc/supervisor/conf.d/photoshow.conf
RUN sed -i -e 's/^\(\[supervisord\]\)$/\1\nnodaemon=true/' /etc/supervisord.conf
ADD supervisor.conf /etc/supervisor.d/photoshow.ini
RUN mkdir -p "/var/log/supervisor"

VOLUME ["/opt/PhotoShow", "/var/log"]
EXPOSE 80
Expand Down
14 changes: 14 additions & 0 deletions docker/fpm.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
[www]
user = www-data
group = www-data

listen = /var/run/php/php7.0-fpm.sock
listen.owner = www-data
listen.group = www-data
listen.mode = 0660

pm = dynamic
pm.start_servers = 1
pm.max_children = 5
pm.min_spare_servers = 1
pm.max_spare_servers = 2

php_value[upload_max_filesize] = 14M
php_value[post_max_size] = 14M
php_value[memory_limit] = 96M
Expand Down
2 changes: 1 addition & 1 deletion docker/supervisor.conf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ stopsignal=6
autorestart=true

[program:phpfpm]
command=/usr/sbin/php-fpm7.0
command=/usr/sbin/php-fpm7
stdout_logfile=/var/log/supervisor/%(program_name)s.stdout
stderr_logfile=/var/log/supervisor/%(program_name)s.stderr
stopsignal=6
Expand Down