Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
114 lines (88 loc) · 3.86 KB
/
Copy pathDockerfile
File metadata and controls
114 lines (88 loc) · 3.86 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
# renovate: datasource=github-tags depName=FFmpeg/FFmpeg extractVersion=^n(?<version>.+)$
ARG FFMPEG_VERSION=8.1.2
ARG PHP_VERSION=8.2
# renovate: datasource=github-tags depName=swoole/swoole-src
ARG SWOOLE_VERSION=v6.2.5
FROM php:${PHP_VERSION}-cli-alpine AS ffmpeg
ARG FFMPEG_VERSION
RUN apk add --no-cache \
build-base nasm pkgconf git \
x264-dev x265-dev libvpx-dev opus-dev lame-dev zlib-dev \
libtheora-dev libvorbis-dev
# Cloned from the GitHub mirror at the release tag, like swoole below. ffmpeg.org
# resets or times out connections from CI runners, and retries do not outlast it.
RUN git clone --depth 1 --branch "n${FFMPEG_VERSION}" https://github.com/FFmpeg/FFmpeg.git /tmp/ffmpeg \
&& cd /tmp/ffmpeg \
&& ./configure \
--prefix=/opt/ffmpeg \
--enable-gpl \
--enable-libx264 \
--enable-libx265 \
--enable-libvpx \
--enable-libopus \
--enable-libmp3lame \
--enable-libtheora \
--enable-libvorbis \
--disable-debug \
--disable-doc \
--disable-ffplay \
&& make -j"$(nproc)" \
&& make install \
&& /opt/ffmpeg/bin/ffmpeg -version \
&& rm -rf /tmp/ffmpeg
# Built from source, pinned, in its own stage so it compiles alongside ffmpeg
# rather than after it. Only the tests need it: the library itself has no swoole
# dependency, it just has to keep yielding when a caller runs it in a coroutine,
# and that is only provable with the real scheduler.
FROM php:${PHP_VERSION}-cli-alpine AS swoole
ARG SWOOLE_VERSION
RUN apk add --no-cache \
build-base autoconf openssl-dev linux-headers git file \
&& git clone --depth 1 --branch "${SWOOLE_VERSION}" https://github.com/swoole/swoole-src.git /tmp/swoole \
&& cd /tmp/swoole \
&& phpize \
&& ./configure \
&& make -j"$(nproc)" \
&& make install \
&& mkdir -p /ext \
&& cp "$(php-config --extension-dir)/swoole.so" /ext/swoole.so \
&& rm -rf /tmp/swoole
FROM composer:2@sha256:50ea4d33fdcde1adb0f045547295faa1548b33872e5f789dae5b02ce2fb5de93 AS vendor
ARG TESTING=false
WORKDIR /usr/local/src/
COPY composer.json composer.lock /usr/local/src/
# No --ignore-platform-reqs: the lock is resolved against the oldest supported
# PHP, so anything that would not run in this image should fail the build rather
# than install and break at runtime.
RUN composer install --optimize-autoloader \
--no-plugins --no-scripts --prefer-dist \
$(test "$TESTING" = "true" || echo "--no-dev")
FROM php:${PHP_VERSION}-cli-alpine AS final
LABEL maintainer="team@appwrite.io"
ENV TZ=UTC
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN apk add --no-cache \
x264-libs x265-libs libvpx opus lame-libs libtheora libvorbis libstdc++
COPY --from=ffmpeg /opt/ffmpeg/bin/ffmpeg /opt/ffmpeg/bin/ffprobe /usr/local/bin/
COPY --from=swoole /ext/swoole.so /ext/swoole.so
RUN cp /ext/swoole.so "$(php-config --extension-dir)/" \
&& echo extension=swoole.so > /usr/local/etc/php/conf.d/swoole.ini \
&& rm -rf /ext
# Enough headroom for a cold phpstan run, which needs more than the 128M default.
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" \
&& echo "memory_limit=1024M" >> "$PHP_INI_DIR/php.ini"
WORKDIR /usr/src/code
COPY --from=vendor /usr/local/src/vendor /usr/src/code/vendor
# Add Source Code
COPY ./src /usr/src/code/src
COPY ./tests /usr/src/code/tests
COPY ./composer.json /usr/src/code/composer.json
COPY ./phpunit.xml /usr/src/code/phpunit.xml
COPY ./phpstan.neon /usr/src/code/phpstan.neon
COPY ./pint.json /usr/src/code/pint.json
# Asserted rather than printed: without this the coroutine suite would go back to
# skipping itself, and a skipped test is quiet about being absent.
RUN ffmpeg -version && ffprobe -version \
&& php --ri swoole > /dev/null \
&& php -r 'exit(extension_loaded("swoole") ? 0 : 1);'
CMD [ "tail", "-f", "/dev/null" ]