Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
397 lines (359 loc) · 12.9 KB
/
Copy pathDockerfile
File metadata and controls
397 lines (359 loc) · 12.9 KB
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
# Pin php:8.5-alpine by multi-arch index digest. Bump with:
# docker buildx imagetools inspect php:8.5-alpine | head -2
ARG BASE_IMAGE="php:8.5-alpine@sha256:b3ef44e3c43f8fc0d0deca8ae318f4e4a9b8eb1809617b66e09c915fcaad04c8"
FROM $BASE_IMAGE AS trusted-base
# Distrust the compromised eMudhra chains before build-time or runtime HTTPS.
RUN apk add --no-cache 'ca-certificates>=20261020-r0' 'ca-certificates-bundle>=20261020-r0' && \
update-ca-certificates
FROM trusted-base AS compile
# Every source is fetched by immutable reference — a commit SHA for git, a
# tarball checksum for PECL — because a tag can be repointed at any time. The
# version beside each reference is the release it was resolved from; the
# weekly updater rewrites both together.
ENV \
PHP_BROTLI_VERSION="0.21.1" \
PHP_BROTLI_COMMIT="eaa63da67ae9ae7bbb5afbb52a185703bad70389" \
PHP_LZ4_VERSION="0.8.0" \
PHP_LZ4_COMMIT="7406b442fa02f71baa39f207bd79d90765e11331" \
PHP_MAXMINDDB_VERSION="v1.14.0" \
PHP_MAXMINDDB_COMMIT="f3c92f68b3bec42a9aa780368399e03dc6b91e89" \
PHP_MONGODB_VERSION="2.5.5" \
PHP_MONGODB_COMMIT="515d38e6bf97dcbe57ae4af6e284bee964d787dd" \
PHP_PROTOBUF_VERSION="5.36.2" \
PHP_PROTOBUF_CHECKSUM="f0a17c67de29df0fb0e5215a381df9b155125e1ace6252dd617bf16b4194dd5b" \
PHP_REDIS_VERSION="6.3.0" \
PHP_REDIS_COMMIT="df4fab2de7fc327c54c94a13af2b9542e4fbd720" \
PHP_SCRYPT_VERSION="2.0.2" \
PHP_SCRYPT_COMMIT="5a14bc766423dac3f868792fa8c41f85f47263ec" \
PHP_SNAPPY_VERSION="0.2.3" \
PHP_SNAPPY_COMMIT="d31b77d63955dbbf1a302ca13c4795292f91d140" \
PHP_SWOOLE_VERSION="v0.1.5" \
PHP_SWOOLE_COMMIT="4c445ce8a9c6e811f4caef5d1b6eed8d6bf78518" \
PHP_YAML_VERSION="2.3.0" \
PHP_YAML_COMMIT="c1f0d8ba5ef3884846261bbdb91c2ab0b07db44c" \
PHP_ZSTD_VERSION="0.18.0" \
PHP_ZSTD_COMMIT="c2593a4ce2457b23e7fa7f81ddf0dd9bbdd89b47"
# libcurl 8.22.0 fixes retained TLS shutdown sockets in the socket-action API
# used by Swoole's curl hook (curl/curl#22282). Require it here and at runtime.
RUN \
apk update && \
apk upgrade --no-cache && \
apk add --no-cache \
autoconf \
automake \
brotli-dev \
c-ares-dev \
curl \
'curl-dev>=8.22.0' \
g++ \
gcc \
git \
freetype-dev \
icu-dev \
libavif-dev \
libjpeg-turbo-dev \
libwebp-dev \
libmaxminddb-dev \
libpng-dev \
linux-headers \
lz4-dev \
make \
openssl-dev \
postgresql-dev \
yaml-dev \
zlib-dev \
zstd-dev && \
mkdir -p /artifacts && \
docker-php-ext-install -j"$(nproc)" sockets
# Each builder stage emits a stripped .so to /artifacts/<name>.so so the
# final image doesn't need to know PHP's module-API date directory.
FROM compile AS redis
RUN \
git init redis && \
cd redis && \
git fetch --depth 1 https://github.com/phpredis/phpredis.git $PHP_REDIS_COMMIT && \
git checkout FETCH_HEAD && \
phpize && \
./configure && \
make -j"$(nproc)" && make install && \
cp $(php-config --extension-dir)/redis.so /artifacts/ && \
strip /artifacts/redis.so
FROM compile AS yaml
RUN \
git init yaml && \
cd yaml && \
git fetch --depth 1 https://github.com/php/pecl-file_formats-yaml $PHP_YAML_COMMIT && \
git checkout FETCH_HEAD && \
phpize && \
./configure && \
make -j"$(nproc)" && make install && \
cp $(php-config --extension-dir)/yaml.so /artifacts/ && \
strip /artifacts/yaml.so
FROM compile AS maxmind
RUN \
git init maxminddb && \
cd maxminddb && \
git fetch --depth 1 https://github.com/maxmind/MaxMind-DB-Reader-php.git $PHP_MAXMINDDB_COMMIT && \
git checkout FETCH_HEAD && \
cd ext && \
phpize && \
./configure && \
make -j"$(nproc)" && make install && \
cp $(php-config --extension-dir)/maxminddb.so /artifacts/ && \
strip /artifacts/maxminddb.so
FROM compile AS mongodb
RUN \
git init mongodb && \
cd mongodb && \
git fetch --depth 1 https://github.com/mongodb/mongo-php-driver.git $PHP_MONGODB_COMMIT && \
git checkout FETCH_HEAD && \
git submodule update --init && \
phpize && \
./configure && \
make -j"$(nproc)" && make install && \
cp $(php-config --extension-dir)/mongodb.so /artifacts/ && \
strip /artifacts/mongodb.so
FROM compile AS zstd
RUN \
git init zstd && \
cd zstd && \
git fetch --depth 1 https://github.com/kjdev/php-ext-zstd.git $PHP_ZSTD_COMMIT && \
git checkout FETCH_HEAD && \
git submodule update --init --recursive && \
phpize && \
./configure --with-libzstd && \
make -j"$(nproc)" && make install && \
cp $(php-config --extension-dir)/zstd.so /artifacts/ && \
strip /artifacts/zstd.so
FROM compile AS brotli
RUN \
git init brotli && \
cd brotli && \
git fetch --depth 1 https://github.com/kjdev/php-ext-brotli.git $PHP_BROTLI_COMMIT && \
git checkout FETCH_HEAD && \
phpize && \
./configure --with-libbrotli && \
make -j"$(nproc)" && make install && \
cp $(php-config --extension-dir)/brotli.so /artifacts/ && \
strip /artifacts/brotli.so
# igbinary 3.2.17RC1 is the first tag that builds on PHP 8.5, and no final
# 3.2.17 exists yet. The dependency updater only understands x.y.z pins, so the
# commit is inlined here rather than declared as PHP_IGBINARY_VERSION/COMMIT;
# move it into the catalog (.github/scripts/src/Dependency/Catalog.php) once
# igbinary tags a final release.
FROM compile AS igbinary
RUN \
git init igbinary && \
cd igbinary && \
git fetch --depth 1 https://github.com/igbinary/igbinary.git edda7101adf583df047d028a154abf3bf04ced61 && \
git checkout FETCH_HEAD && \
phpize && \
./configure && \
make -j"$(nproc)" && make install && \
cp $(php-config --extension-dir)/igbinary.so /artifacts/ && \
strip /artifacts/igbinary.so
FROM compile AS lz4
RUN \
git init lz4 && \
cd lz4 && \
git fetch --depth 1 https://github.com/kjdev/php-ext-lz4.git $PHP_LZ4_COMMIT && \
git checkout FETCH_HEAD && \
git submodule update --init --recursive && \
phpize && \
./configure --with-lz4-includedir=/usr && \
make -j"$(nproc)" && make install && \
cp $(php-config --extension-dir)/lz4.so /artifacts/ && \
strip /artifacts/lz4.so
FROM compile AS snappy
RUN \
git init snappy && \
cd snappy && \
git fetch --depth 1 https://github.com/kjdev/php-ext-snappy.git $PHP_SNAPPY_COMMIT && \
git checkout FETCH_HEAD && \
git submodule update --init --recursive && \
phpize && \
./configure && \
make -j"$(nproc)" && make install && \
cp $(php-config --extension-dir)/snappy.so /artifacts/ && \
strip /artifacts/snappy.so
FROM compile AS scrypt
RUN \
git init scrypt && \
cd scrypt && \
git fetch --depth 1 https://github.com/DomBlack/php-scrypt.git $PHP_SCRYPT_COMMIT && \
git checkout FETCH_HEAD && \
phpize && \
./configure --enable-scrypt && \
make -j"$(nproc)" && make install && \
cp $(php-config --extension-dir)/scrypt.so /artifacts/ && \
strip /artifacts/scrypt.so
FROM compile AS protobuf
RUN curl -fsSL -o protobuf.tgz \
https://pecl.php.net/get/protobuf-${PHP_PROTOBUF_VERSION}.tgz && \
echo "${PHP_PROTOBUF_CHECKSUM} protobuf.tgz" | sha256sum -c - && \
MAKEFLAGS="-j$(nproc)" pecl install protobuf.tgz && \
cp $(php-config --extension-dir)/protobuf.so /artifacts/ && \
strip /artifacts/protobuf.so
FROM compile AS core-extensions
RUN docker-php-ext-configure gd \
--with-avif \
--with-freetype \
--with-jpeg \
--with-webp && \
docker-php-ext-install -j"$(nproc)" gd intl pdo_mysql pdo_pgsql && \
cp \
$(php-config --extension-dir)/gd.so \
$(php-config --extension-dir)/intl.so \
$(php-config --extension-dir)/pdo_mysql.so \
$(php-config --extension-dir)/pdo_pgsql.so \
$(php-config --extension-dir)/sockets.so \
/artifacts/ && \
strip \
/artifacts/gd.so \
/artifacts/intl.so \
/artifacts/pdo_mysql.so \
/artifacts/pdo_pgsql.so \
/artifacts/sockets.so
# Swoole is appwrite-labs/swoole-rs: Swoole v6.2.6's PHP extension rewritten in
# Rust and built by Cargo, so PHP_SWOOLE_VERSION is a swoole-rs release while
# the extension reports 6.2.6. Brotli, zstd, OpenSSL and sockets are built in;
# the --configure switches are the rest of upstream's. Built without --stdext:
# stdext registers user opcode handlers, which makes opcache's JIT refuse to
# enable in downstream images. rust-toolchain.toml in the source picks Rust.
FROM compile AS swoole
RUN \
apk add --no-cache clang-dev pcre2-dev pkgconf python3 rustup && \
rustup-init -y --profile minimal --default-toolchain none && \
. "$HOME/.cargo/env" && \
git init swoole && \
cd swoole && \
git fetch --depth 1 https://github.com/appwrite-labs/swoole-rs.git $PHP_SWOOLE_COMMIT && \
git checkout FETCH_HEAD && \
rustup toolchain install && \
RUSTFLAGS="-C target-feature=-crt-static" python3 tools/build_ext.py \
--php-sockets \
--configure=--enable-cares \
--configure=--enable-mysqlnd \
--configure=--enable-swoole-curl \
--configure=--enable-swoole-pgsql && \
cp target/ext/swoole.so /artifacts/ && \
strip /artifacts/swoole.so
# git-remote-entire, git's remote helper for entire:// URLs: Entire serves git
# only through it, so Appwrite clones Entire repositories with it. Built from
# the pinned commit the way upstream's release builds it (.goreleaser.yaml),
# static so it runs on Alpine. Tagging the commit with the version it was
# resolved from lets go stamp that version into the build info, as upstream's
# tag build does; scanners read it to decide which advisories apply.
# Go 1.27.3 also rejects the compromised eMudhra intermediates in crypto/x509.
FROM golang:1.27.4-alpine@sha256:0a5f7fe796599ff487605987432e7619ae45beeb2fba4c2ce0b907879932aebf AS entire
ENV \
ENTIRE_CLI_VERSION="v0.12.2" \
ENTIRE_CLI_COMMIT="c4f103d8dfed1f1549db9b2c793f2d7e10f65eb8" \
ENTIRE_CLI_X_NET_VERSION="v0.62.0"
RUN \
apk add --no-cache git 'ca-certificates>=20261020-r0' 'ca-certificates-bundle>=20261020-r0' && \
update-ca-certificates && \
mkdir -p /artifacts && \
git init cli && \
cd cli && \
git fetch --depth 1 https://github.com/entireio/cli.git $ENTIRE_CLI_COMMIT && \
git checkout FETCH_HEAD && \
go get golang.org/x/net@$ENTIRE_CLI_X_NET_VERSION && \
git -c user.name=docker-base -c user.email=docker-base@appwrite.io commit -qam "golang.org/x/net $ENTIRE_CLI_X_NET_VERSION" && \
git tag $ENTIRE_CLI_VERSION && \
CGO_ENABLED=0 go build -trimpath \
-ldflags "-s -w \
-X github.com/entireio/cli/cmd/entire/cli/versioninfo.Version=${ENTIRE_CLI_VERSION#v} \
-X github.com/entireio/cli/cmd/entire/cli/versioninfo.Commit=$(git rev-parse --short HEAD^)" \
-o /artifacts/git-remote-entire \
./cmd/git-remote-entire
FROM trusted-base AS final
ARG BASE_IMAGE
LABEL base_image=$BASE_IMAGE
LABEL maintainer="team@appwrite.io"
RUN apk update && \
apk upgrade --no-cache && \
apk add --no-cache \
brotli \
c-ares \
certbot \
freetype \
docker-cli \
docker-cli-compose \
exiftool \
'git>=2.54.1-r0' \
icu-libs \
libavif \
'libcurl>=8.22.0' \
libgomp \
libheif \
libheif-aom \
libjpeg-turbo \
libmaxminddb \
libpng \
libpq \
libstdc++ \
libwebp \
lz4-libs \
rsync \
yaml \
zip \
zstd-libs \
&& rm -rf /var/cache/apk/*
WORKDIR /usr/src/code
COPY --from=core-extensions /artifacts/ /tmp/exts/
COPY --from=brotli /artifacts/ /tmp/exts/
COPY --from=igbinary /artifacts/ /tmp/exts/
COPY --from=lz4 /artifacts/ /tmp/exts/
COPY --from=maxmind /artifacts/ /tmp/exts/
COPY --from=mongodb /artifacts/ /tmp/exts/
COPY --from=protobuf /artifacts/ /tmp/exts/
COPY --from=redis /artifacts/ /tmp/exts/
COPY --from=scrypt /artifacts/ /tmp/exts/
COPY --from=snappy /artifacts/ /tmp/exts/
COPY --from=swoole /artifacts/ /tmp/exts/
COPY --from=yaml /artifacts/ /tmp/exts/
COPY --from=zstd /artifacts/ /tmp/exts/
RUN cp /tmp/exts/*.so $(php-config --extension-dir)/ && \
rm -rf /tmp/exts && \
docker-php-ext-enable \
brotli \
gd \
igbinary \
intl \
lz4 \
maxminddb \
mongodb \
pdo_mysql \
pdo_pgsql \
protobuf \
redis \
scrypt \
snappy \
sockets \
swoole \
yaml \
zstd
COPY --from=entire /artifacts/git-remote-entire /usr/local/bin/git-remote-entire
EXPOSE 80
CMD [ "tail", "-f", "/dev/null" ]
# XDebug variant — build with: docker build --target xdebug -t appwrite/base:XYZ-xdebug .
FROM compile AS xdebug-build
ENV \
PHP_XDEBUG_VERSION="3.5.3" \
PHP_XDEBUG_COMMIT="127bbcb980400752221cfaa54bdc1420e6ef3c12"
RUN \
git init xdebug && \
cd xdebug && \
git fetch --depth 1 https://github.com/xdebug/xdebug $PHP_XDEBUG_COMMIT && \
git checkout FETCH_HEAD && \
phpize && \
./configure && \
make -j"$(nproc)" && make install && \
cp $(php-config --extension-dir)/xdebug.so /artifacts/ && \
strip /artifacts/xdebug.so
FROM final AS xdebug
COPY --from=xdebug-build /artifacts/xdebug.so /tmp/
RUN cp /tmp/xdebug.so $(php-config --extension-dir)/ && \
rm /tmp/xdebug.so && \
docker-php-ext-enable xdebug