-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Dockerfile-nts-alpine
140 lines (109 loc) · 4.37 KB
/
Dockerfile-nts-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
139
140
# syntax=docker/dockerfile:experimental
ARG PHP_VERSION=7.4
ARG OS_VERSION=alpine3.11
FROM php:$PHP_VERSION-cli-$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 nts-slim-root
COPY --from=build-uv /uv.so /uv.so
# Install docker help scripts
COPY src/php/utils/docker/ /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` && \
mv /*.so "$EXTENSION_DIR/" && \
apk add --no-cache \
libuv-dev \
icu-dev \
libevent-dev \
openssl-dev \
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 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"]
## NTS-DEV STAGE ##
FROM nts-slim-root AS nts-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
## NTS-DEV STAGE ##
FROM nts-slim-root AS nts-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
COPY src/php/utils/docker/alpine/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 \
&& rm /usr/local/etc/php/conf.d/jit.ini
# Install composer
COPY --from=composer:2 /usr/bin/composer /usr/local/bin/composer
ENTRYPOINT ["docker-php-entrypoint"]
## NTS-DEV STAGE ##
FROM nts-root AS nts-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
COPY src/php/utils/docker/alpine/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 \
&& rm /usr/local/etc/php/conf.d/jit.ini
# Install composer
COPY --from=composer:2 /usr/bin/composer /usr/local/bin/composer
ENTRYPOINT ["docker-php-entrypoint"]
## NTS-DEV stage ##
FROM nts-slim-dev-root AS nts-slim-dev
USER app
FROM nts-dev-root AS nts-dev
USER app
## NTS stage ##
FROM nts-slim-root AS nts-slim
USER app
FROM nts-root AS nts
USER app