-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Dockerfile-zts-debian
154 lines (122 loc) · 4.83 KB
/
Dockerfile-zts-debian
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# syntax=docker/dockerfile:experimental
ARG PHP_VERSION=7.4
ARG OS_VERSION=buster
FROM php:$PHP_VERSION-zts-$OS_VERSION AS base
# Build-time metadata as defined at http://label-schema.org
LABEL org.label-schema.name="wyrihaximusnet/php" \
org.label-schema.description="Opinionated ReactPHP optimised PHP Docker images" \
org.label-schema.url="https://github.com/wyrihaximusnet/docker-php" \
org.label-schema.vcs-url="https://github.com/wyrihaximusnet/docker-php" \
org.label-schema.vendor="WyriHaximus.net" \
org.label-schema.schema-version="1.0"
ARG ARCH=amd64
RUN apt-get update \
&& yes | apt-get upgrade \
&& set -x \
&& addgroup --gid 1000 app \
&& adduser --uid 1000 --gid 1000 --disabled-password app --home /opt/app \
&& touch /.you-are-in-a-wyrihaximus.net-php-docker-image
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/
FROM base AS base-build
RUN yes | apt-get install $PHPIZE_DEPS git libuv1-dev
FROM base-build AS build-uv
RUN git clone https://github.com/amphp/ext-uv uv
WORKDIR /uv
RUN git fetch \
&& git pull \
&& phpize \
&& ./configure \
&& make install \
&& EXTENSION_DIR=`php-config --extension-dir 2>/dev/null` \
&& cp "$EXTENSION_DIR/uv.so" /uv.so \
&& sha256sum /uv.so
FROM base AS zts-slim-root
COPY --from=build-uv /uv.so /uv.so
# Patch CVE-2018-14618 (curl), CVE-2018-16842 (libxml2), CVE-2019-1543 (openssl)
RUN yes | apt-get upgrade curl libxml2 openssl
# Install docker help scripts
COPY src/php/utils/docker/debian/ /usr/local/bin/
COPY src/php/conf/ /usr/local/etc/php/conf.d/
COPY src/php/cli/conf/*.ini /usr/local/etc/php/conf.d/
RUN EXTENSION_DIR=`php-config --extension-dir 2>/dev/null` && \
rm /usr/local/etc/php/conf.d/jit.ini && \
mv /*.so "$EXTENSION_DIR/" && \
yes | apt-get install \
libgmp-dev \
zlib1g-dev \
libpq-dev \
libzip-dev \
libuv1-dev \
libicu-dev \
libevent-dev \
libssl-dev \
make \
git \
openssh-client \
bash \
coreutils \
procps \
git \
wget \
gdb \
$PHPIZE_DEPS \
&& docker-php-ext-install -j$(nproc) pcntl pgsql pdo pdo_pgsql bcmath zip gmp iconv intl sockets \
&& (docker-php-ext-install -j$(nproc) random || true) \
&& pecl install parallel || pecl install parallel-1.1.4 \
&& docker-php-ext-enable parallel \
&& (pecl install eio || pecl install eio-beta) \
&& docker-php-ext-enable eio \
&& pecl install event \
# To ensure ext-socket loads before ext-event
&& docker-php-ext-enable --ini-name zzzzz-event.ini event \
&& docker-php-ext-enable uv \
&& wget -q -O - https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh > /bin/wait-for \
&& chmod +x /bin/wait-for \
&& yes | apt-get purge wget $PHPIZE_DEPS \
&& yes | apt-get install make \
&& rm -rf /var/cache/apk/* \
&& rm -rf /tmp/*
STOPSIGNAL SIGTERM
ENTRYPOINT ["docker-php-entrypoint"]
## ZTS-DEV STAGE ##
FROM zts-slim-root AS zts-root
# Install ext-gd and ext-vips
COPY src/php/utils/docker/debian/install-gd-and-vips /usr/local/bin/install-gd-and-vips
RUN if [ $(php -v | grep "alpha\|ALPHA\|beta\|BETA\|rc\|RC" | wc -l) != 0 ] ; then true ; else install-gd-and-vips; fi \
&& rm -rf /usr/local/bin/install-gd-and-vips
## ZTS-DEV STAGE ##
FROM zts-slim-root AS zts-slim-dev-root
RUN touch /.you-are-in-a-wyrihaximus.net-php-docker-image-dev
# Install docker help scripts
COPY src/php/utils/docker/debian/dev-mode /usr/local/bin/dev-mode
COPY src/php/utils/docker/debian/docker-php-dev-mode /usr/local/bin/docker-php-dev-mode
RUN if [ $(php -v | grep "alpha\|ALPHA\|beta\|BETA\|rc\|RC" | wc -l) != 0 ] ; then true ; else dev-mode; fi \
&& rm -rf /usr/local/bin/dev-mode \
&& rm -rf /usr/local/bin/docker-php-dev-mode \
&& yes | apt-get install make
# Install composer
COPY --from=composer:2 /usr/bin/composer /usr/local/bin/composer
ENTRYPOINT ["docker-php-entrypoint"]
## ZTS-DEV STAGE ##
FROM zts-root AS zts-dev-root
RUN touch /.you-are-in-a-wyrihaximus.net-php-docker-image-dev
# Install docker help scripts
COPY src/php/utils/docker/debian/dev-mode /usr/local/bin/dev-mode
COPY src/php/utils/docker/debian/docker-php-dev-mode /usr/local/bin/docker-php-dev-mode
RUN if [ $(php -v | grep "alpha\|ALPHA\|beta\|BETA\|rc\|RC" | wc -l) != 0 ] ; then true ; else dev-mode; fi \
&& rm -rf /usr/local/bin/dev-mode \
&& rm -rf /usr/local/bin/docker-php-dev-mode \
&& yes | apt-get install make
# Install composer
COPY --from=composer:2 /usr/bin/composer /usr/local/bin/composer
ENTRYPOINT ["docker-php-entrypoint"]
## ZTS-DEV stage ##
FROM zts-slim-dev-root AS zts-slim-dev
USER app
FROM zts-dev-root AS zts-dev
USER app
## ZTS stage ##
FROM zts-slim-root AS zts-slim
USER app
FROM zts-root AS zts
USER app