Skip to content

Commit b9cfc94

Browse files
committed
Use upstream PHP base image
1 parent 0c772a5 commit b9cfc94

File tree

4 files changed

+90
-88
lines changed

4 files changed

+90
-88
lines changed

Dockerfile

+86-84
Original file line numberDiff line numberDiff line change
@@ -1,100 +1,102 @@
1-
FROM nginx:1.15.12-alpine
1+
FROM php:7.1-fpm-alpine
22

3-
EXPOSE 8000
4-
CMD ["/sbin/entrypoint.sh"]
5-
6-
ARG cachet_ver
7-
ARG archive_url
8-
9-
ENV cachet_ver ${cachet_ver:-2.4}
10-
ENV archive_url ${archive_url:-https://github.com/cachethq/Cachet/archive/${cachet_ver}.tar.gz}
11-
12-
ENV COMPOSER_VERSION 1.6.3
3+
LABEL maintainer="Alt Three <[email protected]>"
134

14-
RUN apk add --no-cache --update \
15-
postgresql-client \
16-
postgresql \
17-
mysql-client \
18-
php7 \
19-
php7-redis \
20-
php7-apcu \
21-
php7-bcmath \
22-
php7-dom \
23-
php7-ctype \
24-
php7-curl \
25-
php7-fpm \
26-
php7-fileinfo \
27-
php7-gd \
28-
php7-iconv \
29-
php7-intl \
30-
php7-json \
31-
sqlite \
32-
php7-mbstring \
33-
php7-mcrypt \
34-
php7-mysqlnd \
35-
php7-opcache \
36-
php7-openssl \
37-
php7-pdo \
38-
php7-pdo_mysql \
39-
php7-pdo_pgsql \
40-
php7-pdo_sqlite \
41-
php7-phar \
42-
php7-posix \
43-
php7-session \
44-
php7-sqlite3 \
45-
php7-simplexml \
46-
php7-soap \
47-
php7-xml \
48-
php7-xmlwriter \
49-
php7-zip \
50-
php7-zlib \
51-
php7-tokenizer \
52-
wget sqlite git curl bash grep \
53-
supervisor
5+
# entrypoint.sh dependencies
6+
RUN apk add --no-cache \
7+
bash \
8+
nginx \
9+
postgresql-client \
10+
supervisor
5411

55-
# forward request and error logs to docker log collector
56-
RUN ln -sf /dev/stdout /var/log/nginx/access.log && \
57-
ln -sf /dev/stderr /var/log/nginx/error.log && \
58-
ln -sf /dev/stdout /var/log/php7/error.log && \
59-
ln -sf /dev/stderr /var/log/php7/error.log
12+
# Install PHP extensions
13+
RUN set -eux; \
14+
\
15+
apk add --no-cache --virtual .build-deps \
16+
$PHPIZE_DEPS \
17+
libjpeg-turbo-dev \
18+
libmcrypt-dev \
19+
libmemcached-dev \
20+
libpng-dev \
21+
openldap-dev \
22+
pcre-dev \
23+
postgresql-dev \
24+
sqlite-dev \
25+
; \
26+
\
27+
docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr; \
28+
docker-php-ext-install \
29+
gd \
30+
mysqli \
31+
opcache \
32+
pdo_mysql \
33+
pdo_pgsql \
34+
pdo_sqlite \
35+
pgsql \
36+
zip \
37+
; \
38+
\
39+
# pecl will claim success even if one install fails, so we need to perform each install separately
40+
pecl install APCu-5.1.17; \
41+
pecl install redis-4.3.0; \
42+
\
43+
docker-php-ext-enable \
44+
apcu \
45+
redis \
46+
; \
47+
\
48+
runDeps="$( \
49+
scanelf --needed --nobanner --format '%n#p' --recursive /usr/local/lib/php/extensions \
50+
| tr ',' '\n' \
51+
| sort -u \
52+
| awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \
53+
)"; \
54+
apk add --virtual .postfixadmin-phpexts-rundeps $runDeps; \
55+
apk del .build-deps
6056

61-
RUN adduser -S -s /bin/bash -u 1001 -G root www-data
57+
# set recommended PHP.ini settings
58+
# see https://secure.php.net/manual/en/opcache.installation.php
59+
RUN { \
60+
echo 'opcache.memory_consumption=128'; \
61+
echo 'opcache.interned_strings_buffer=8'; \
62+
echo 'opcache.max_accelerated_files=4000'; \
63+
echo 'opcache.revalidate_freq=2'; \
64+
echo 'opcache.fast_shutdown=1'; \
65+
} > /usr/local/etc/php/conf.d/opcache-recommended.ini
6266

63-
RUN touch /var/run/nginx.pid && \
64-
chown -R www-data:root /var/run/nginx.pid /etc/php7/php-fpm.d
65-
66-
RUN mkdir -p /var/www/html && \
67-
mkdir -p /usr/share/nginx/cache && \
68-
mkdir -p /var/cache/nginx && \
69-
mkdir -p /var/lib/nginx && \
70-
chown -R www-data:root /var/www /usr/share/nginx/cache /var/cache/nginx /var/lib/nginx/
67+
#VOLUME /var/www/html
68+
ENV COMPOSER_VERSION 1.8.6
7169

7270
# Install composer
73-
RUN wget https://getcomposer.org/installer -O /tmp/composer-setup.php && \
74-
wget https://composer.github.io/installer.sig -O /tmp/composer-setup.sig && \
75-
php -r "if (hash('SHA384', file_get_contents('/tmp/composer-setup.php')) !== trim(file_get_contents('/tmp/composer-setup.sig'))) { unlink('/tmp/composer-setup.php'); echo 'Invalid installer' . PHP_EOL; exit(1); }" && \
76-
php /tmp/composer-setup.php --version=$COMPOSER_VERSION --install-dir=bin && \
77-
php -r "unlink('/tmp/composer-setup.php');"
71+
RUN set -eux; \
72+
curl -fsSL https://getcomposer.org/installer -o /tmp/composer-setup.php; \
73+
curl -fsSL https://composer.github.io/installer.sig -o /tmp/composer-setup.sig; \
74+
php -r "if (hash('SHA384', file_get_contents('/tmp/composer-setup.php')) !== trim(file_get_contents('/tmp/composer-setup.sig'))) { unlink('/tmp/composer-setup.php'); echo 'Invalid installer' . PHP_EOL; exit(1); }"; \
75+
php /tmp/composer-setup.php --version=$COMPOSER_VERSION --install-dir=/bin; \
76+
php -r "unlink('/tmp/composer-setup.php');"
77+
78+
ARG cachet_ver=2.3.18
79+
ARG archive_url=https://github.com/CachetHQ/Cachet/archive/v${cachet_ver}.tar.gz
7880

79-
WORKDIR /var/www/html/
80-
USER 1001
81+
ENV cachet_ver ${cachet_ver}
82+
ENV archive_url ${archive_url}
8183

82-
RUN wget ${archive_url} && \
83-
tar xzf ${cachet_ver}.tar.gz --strip-components=1 && \
84-
chown -R www-data:root /var/www/html && \
85-
rm -r ${cachet_ver}.tar.gz && \
86-
php /bin/composer.phar global require "hirak/prestissimo:^0.3" && \
87-
php /bin/composer.phar install -o && \
88-
rm -rf bootstrap/cache/*
84+
RUN set -eux; \
85+
curl -o cachet.tar.gz -fSL "${archive_url}"; \
86+
# upstream tarball include ./Cachet-${cachet_ver}/
87+
tar -xf cachet.tar.gz -C /var/www/html --strip-components=1; \
88+
rm cachet.tar.gz; \
89+
composer.phar global require "hirak/prestissimo:^0.3"; \
90+
composer.phar install -q -o; \
91+
rm -rf bootstrap/cache/* ~/.composer /bin/composer.phar; \
92+
chown -R www-data:www-data /var/www/html
8993

9094
COPY conf/php-fpm-pool.conf /etc/php7/php-fpm.d/www.conf
9195
COPY conf/supervisord.conf /etc/supervisor/supervisord.conf
9296
COPY conf/nginx.conf /etc/nginx/nginx.conf
9397
COPY conf/nginx-site.conf /etc/nginx/conf.d/default.conf
9498
COPY conf/.env.docker /var/www/html/.env
95-
COPY entrypoint.sh /sbin/entrypoint.sh
99+
COPY entrypoint.sh /usr/local/bin/
96100

97-
USER root
98-
RUN chmod g+rwx /var/run/nginx.pid && \
99-
chmod -R g+rw /var/www /usr/share/nginx/cache /var/cache/nginx /var/lib/nginx/ /etc/php7/php-fpm.d storage
100-
USER 1001
101+
EXPOSE 8000
102+
CMD ["entrypoint.sh"]

conf/nginx.conf

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ http {
2626

2727
keepalive_timeout 65;
2828

29-
fastcgi_cache_path /usr/share/nginx/cache/fcgi levels=1:2 keys_zone=microcache:10m max_size=1024m inactive=1h;
29+
fastcgi_cache_path /var/lib/nginx/tmp levels=1:2 keys_zone=microcache:10m max_size=1024m inactive=1h;
3030
add_header X-Cache $upstream_cache_status;
3131

3232
gzip on;

conf/supervisord.conf

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ stdout_logfile=/dev/stdout
2525
stderr_logfile=/dev/stderr
2626

2727
[program:php-fpm]
28-
command=/usr/sbin/php-fpm7 -c /etc/php7/fpm/pool.d/www.conf
28+
command=/usr/local/sbin/php-fpm -c /etc/php7/fpm/pool.d/www.conf
2929
catch_workers_output = Yes
3030
stdout_events_enabled=true
3131
stderr_events_enabled=true

entrypoint.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
2-
set -o errexit -o nounset -o pipefail
2+
set -euo pipefail
33

44
[ "${DEBUG:-false}" == true ] && set -x
55

@@ -204,7 +204,7 @@ initialize_system() {
204204

205205
init_db() {
206206
echo "Initializing Cachet database ..."
207-
php artisan cachet:install --no-interaction
207+
php artisan app:install --no-interaction
208208
check_configured
209209
}
210210

0 commit comments

Comments
 (0)