forked from usabilla/php-docker-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile-cli
69 lines (54 loc) · 2.66 KB
/
Dockerfile-cli
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# syntax=docker/dockerfile:experimental
FROM php:7.2-cli-alpine3.7 as cli
# Add usabilla user and group
RUN set -x \
&& addgroup -g 1000 app \
&& adduser -u 1000 -D -G app app \
# Temporary fix: pulls in the aports patch for https://bugs.alpinelinux.org/issues/10648
&& apk add --no-cache --upgrade apk-tools
# Install docker help scripts
COPY src/php/utils/docker/ /usr/local/bin/
# Install PHP extensions
# hadolint ignore=DL4006
RUN set -x \
# Install curl-dev in order to address the curl binary issue in some Alpine versions
&& apk add --no-cache curl-dev \
# Adding sodium purely for the 7.1 image, it's already in 7.2 and up: https://www.php.net/manual/en/sodium.installation.php \
&& apk add --no-cache wget \
&& if [ $(php -v | grep "PHP 7.1" | wc -l) != 0 ] ; then apk add --no-cache libsodium-dev; else true; fi \
&& apk add --no-cache --virtual .phpize-deps $PHPIZE_DEPS \
&& docker-php-ext-install pcntl opcache \
&& pecl install apcu \
&& if [ $(php -v | grep "PHP 7.1" | wc -l) != 0 ] ; then pecl install libsodium; else true; fi \
&& pecl clear-cache \
&& docker-php-ext-enable apcu \
&& docker-php-ext-enable sodium \
# Removing all PHP leftovers since the helper scripts nor the official image are removing them
&& docker-php-source-tarball clean && rm /usr/local/bin/php-cgi && rm /usr/local/bin/phpdbg && rm -rf /tmp/pear ~/.pearrc \
&& apk del .phpize-deps \
# Patch CVE-2018-14618 (curl), CVE-2018-16842 (libxml2), CVE-2019-11068 (libxslt)
&& apk upgrade --no-cache curl libxml2 libxslt \
# Create a symlink to the recommended production configuration
# ref: https://github.com/docker-library/docs/tree/master/php#configuration
&& ln -s $PHP_INI_DIR/php.ini-production $PHP_INI_DIR/php.ini
COPY src/gpg /usr/local/etc/gpg
COPY src/php/conf/ /usr/local/etc/php/conf.d/
COPY src/php/cli/conf/*.ini /usr/local/etc/php/conf.d/
# Install shush
COPY src/php/utils/install-shush /usr/local/bin/
RUN install-shush && rm -rf /usr/local/bin/install-shush
# Install composer
COPY src/php/utils/install-composer /usr/local/bin/
RUN install-composer && rm -rf /usr/local/bin/install-composer
STOPSIGNAL SIGTERM
ENTRYPOINT ["/usr/local/bin/shush", "exec", "docker-php-entrypoint"]
# Base images don't need healthcheck since they are not running applications
# this can be overriden in the child images
HEALTHCHECK NONE
## CLI-DEV STAGE ##
FROM cli as cli-dev
# Install Xdebug and development specific configuration
RUN docker-php-dev-mode xdebug \
&& docker-php-dev-mode config
# Change entrypoint back to the default because we don't need shush in development
ENTRYPOINT ["docker-php-entrypoint"]