Skip to content

Commit 2818223

Browse files
committed
#36: add Dockerfile
1 parent 5a644b9 commit 2818223

File tree

1 file changed

+105
-0
lines changed

1 file changed

+105
-0
lines changed

Dockerfile

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
# ===== True Async PHP (Linux x64 ZTS Release) =====
2+
# Multi-stage build: builder + runtime
3+
4+
# ---------- BUILDER STAGE ----------
5+
FROM ubuntu:24.04 AS builder
6+
7+
# ---------- 1. System toolchain & libraries ----------
8+
RUN apt-get update && apt-get install -y \
9+
autoconf bison build-essential curl re2c git \
10+
cmake ninja-build wget dos2unix \
11+
libxml2-dev libssl-dev pkg-config libargon2-dev \
12+
libcurl4-openssl-dev libedit-dev libreadline-dev \
13+
libsodium-dev libsqlite3-dev libonig-dev libzip-dev \
14+
libpng-dev libjpeg-dev libwebp-dev libfreetype6-dev \
15+
libgmp-dev libldap2-dev libsasl2-dev libpq-dev \
16+
libmysqlclient-dev libbz2-dev libenchant-2-dev \
17+
libffi-dev libgdbm-dev liblmdb-dev libsnmp-dev \
18+
libtidy-dev libxslt1-dev libicu-dev libpsl-dev
19+
20+
# ---------- 2. libuv 1.49 ----------
21+
RUN wget -q https://github.com/libuv/libuv/archive/v1.49.0.tar.gz \
22+
&& tar -xf v1.49.0.tar.gz \
23+
&& cd libuv-1.49.0 && mkdir build && cd build \
24+
&& cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=OFF \
25+
&& ninja && ninja install && ldconfig \
26+
&& cd / && rm -rf libuv*
27+
28+
# ---------- 3. curl 8.10 ----------
29+
RUN wget -q https://github.com/curl/curl/releases/download/curl-8_10_1/curl-8.10.1.tar.gz \
30+
&& tar -xf curl-8.10.1.tar.gz \
31+
&& cd curl-8.10.1 \
32+
&& ./configure --prefix=/usr/local --with-openssl --enable-shared --disable-static \
33+
&& make -j$(nproc) && make install && ldconfig \
34+
&& cd / && rm -rf curl*
35+
36+
# ---------- 4. PHP sources ----------
37+
RUN git clone --depth=1 --branch=true-async-stable https://github.com/true-async/php-src /usr/src/php-src
38+
39+
# ---------- 5. Copy async extension (Dockerfile in extension root) ----------
40+
RUN mkdir -p /usr/src/php-src/ext/async
41+
COPY . /usr/src/php-src/ext/async
42+
43+
# ---------- 5.1. Fix Windows line endings in config.m4 ----------
44+
RUN dos2unix /usr/src/php-src/ext/async/config.m4
45+
46+
WORKDIR /usr/src/php-src
47+
48+
# ---------- 6. Configure & build PHP ----------
49+
RUN ./buildconf --force && \
50+
./configure \
51+
--prefix=/usr/local \
52+
--with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd \
53+
--with-pgsql --with-pdo-pgsql --with-pdo-sqlite \
54+
--without-pear \
55+
--enable-gd --with-jpeg --with-webp --with-freetype \
56+
--enable-exif --with-zip --with-zlib \
57+
--enable-soap --enable-xmlreader --with-xsl --with-tidy --with-libxml \
58+
--enable-sysvsem --enable-sysvshm --enable-shmop --enable-pcntl \
59+
--with-readline \
60+
--enable-mbstring --with-curl --with-gettext \
61+
--enable-sockets --with-bz2 --with-openssl --with-gmp \
62+
--enable-bcmath --enable-calendar --enable-ftp --with-enchant \
63+
--enable-sysvmsg --with-ffi --enable-dba --with-lmdb --with-gdbm \
64+
--with-snmp --enable-intl --with-ldap --with-ldap-sasl \
65+
--enable-werror \
66+
--with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d \
67+
--disable-debug --enable-zts \
68+
--enable-async && \
69+
make -j$(nproc) && make install
70+
71+
# ---------- 7. Minimal runtime setup ----------
72+
RUN mkdir -p /etc/php.d && echo "opcache.enable_cli=1" > /etc/php.d/opcache.ini
73+
74+
# ---------- RUNTIME STAGE ----------
75+
FROM ubuntu:24.04 AS runtime
76+
77+
# Install only runtime dependencies (no build tools)
78+
RUN apt-get update && apt-get install -y --no-install-recommends \
79+
libxml2 libssl3 libargon2-1 \
80+
libcurl4 libedit2 libreadline8 \
81+
libsodium23 libsqlite3-0 libonig5 libzip4 \
82+
libpng16-16 libjpeg8 libwebp7 libfreetype6 \
83+
libgmp10 libldap2 libsasl2-2 libpq5 \
84+
libmysqlclient21 libbz2-1.0 libenchant-2-2 \
85+
libffi8 libgdbm6 liblmdb0 libsnmp40 \
86+
libtidy5deb1 libxslt1.1 libicu74 libpsl5 \
87+
ca-certificates \
88+
&& rm -rf /var/lib/apt/lists/*
89+
90+
# Copy built PHP and libraries from builder stage
91+
COPY --from=builder /usr/local /usr/local
92+
COPY --from=builder /etc/php.d /etc/php.d
93+
94+
# Update library cache
95+
RUN ldconfig
96+
97+
# Set PATH
98+
ENV PATH="/usr/local/bin:/usr/local/sbin:$PATH"
99+
100+
# Verify PHP installation
101+
RUN php -v
102+
103+
WORKDIR /app
104+
105+
CMD ["php", "-v"]

0 commit comments

Comments
 (0)