-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Dockerfile-zts-alpine
138 lines (107 loc) · 4.2 KB
/
Dockerfile-zts-alpine
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
# syntax=docker/dockerfile:experimental
ARG PHP_VERSION=7.4
ARG OS_VERSION=alpine3.11
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 apk update \
&& apk upgrade \
&& set -x \
&& addgroup -g 1000 app \
&& adduser -u 1000 -D -G app 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 apk add --no-cache $PHPIZE_DEPS git libuv-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
# Install docker help scripts
COPY src/php/utils/docker/alpine/ /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/" && \
apk add --no-cache \
libuv-dev \
icu-dev \
libevent-dev \
openssl-dev \
make \
git \
openssh-client \
bash \
coreutils \
procps \
git \
$PHPIZE_DEPS \
## Install PECL
&& wget -q pear.php.net/go-pear.phar && php go-pear.phar \
&& install-php-extensions pcntl pgsql pdo pdo_pgsql bcmath zip gmp iconv opcache intl sockets \
&& (install-php-extensions 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 \
&& apk del $PHPIZE_DEPS \
&& wget -q -O - https://raw.githubusercontent.com/eficode/wait-for/master/wait-for > /bin/wait-for \
&& chmod +x /bin/wait-for \
&& 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/alpine/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/alpine/dev-mode /usr/local/bin/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
# 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/alpine/dev-mode /usr/local/bin/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
# 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