Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 48 additions & 39 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,29 @@ FROM php-base AS common

WORKDIR /app

RUN apt-get update && \
apt-get -y --no-install-recommends install \
mailcap \
libcap2-bin \
&& \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

RUN set -eux; \
mkdir -p \
/app/public \
/config/caddy \
/data/caddy \
/etc/caddy \
/etc/frankenphp; \
sed -i 's/php/frankenphp run/g' /usr/local/bin/docker-php-entrypoint; \
echo '<?php phpinfo();' > /app/public/index.php
RUN <<EOF
set -e
apt-get update
apt-get -y --no-install-recommends install mailcap libcap2-bin
apt-get clean
rm -rf /var/lib/apt/lists/*
EOF

RUN <<EOF
set -eux
mkdir -p /app/public /config/caddy /data/caddy /etc/caddy /etc/frankenphp
sed -i 's/php/frankenphp run/g' /usr/local/bin/docker-php-entrypoint
echo '<?php phpinfo();' > /app/public/index.php
EOF

COPY --link caddy/frankenphp/Caddyfile /etc/caddy/Caddyfile
RUN ln /etc/caddy/Caddyfile /etc/frankenphp/Caddyfile && \
curl -sSLf \
-o /usr/local/bin/install-php-extensions \
https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions && \
chmod +x /usr/local/bin/install-php-extensions
RUN <<EOF
set -e
ln /etc/caddy/Caddyfile /etc/frankenphp/Caddyfile
curl -sSLf -o /usr/local/bin/install-php-extensions \
https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions
chmod +x /usr/local/bin/install-php-extensions
EOF

CMD ["--config", "/etc/frankenphp/Caddyfile", "--adapter", "caddyfile"]
HEALTHCHECK CMD curl -f http://localhost:2019/metrics || exit 1
Expand Down Expand Up @@ -62,8 +61,10 @@ ENV PATH=/usr/local/go/bin:$PATH
ENV GOTOOLCHAIN=local

# This is required to link the FrankenPHP binary to the PHP binary
RUN apt-get update && \
apt-get -y --no-install-recommends install \
RUN <<EOF
set -e
apt-get update
apt-get -y --no-install-recommends install \
cmake \
git \
libargon2-dev \
Expand All @@ -75,9 +76,9 @@ RUN apt-get update && \
libsqlite3-dev \
libssl-dev \
libxml2-dev \
zlib1g-dev \
&& \
apt-get clean
zlib1g-dev
apt-get clean
EOF

# Install e-dant/watcher (necessary for file watching)
WORKDIR /usr/local/src/watcher
Expand Down Expand Up @@ -117,12 +118,14 @@ ENV CGO_CPPFLAGS=$PHP_CPPFLAGS
ENV CGO_LDFLAGS="-L/usr/local/lib -lssl -lcrypto -lreadline -largon2 -lcurl -lonig -lz $PHP_LDFLAGS"

WORKDIR /go/src/app/caddy/frankenphp
RUN GOBIN=/usr/local/bin \
../../go.sh install -ldflags "-w -s -X 'github.com/caddyserver/caddy/v2.CustomVersion=FrankenPHP $FRANKENPHP_VERSION PHP $PHP_VERSION Caddy' -X 'github.com/caddyserver/caddy/v2.CustomBinaryName=frankenphp' -X 'github.com/caddyserver/caddy/v2/modules/caddyhttp.ServerHeader=FrankenPHP Caddy'" -buildvcs=true && \
setcap cap_net_bind_service=+ep /usr/local/bin/frankenphp && \
cp Caddyfile /etc/frankenphp/Caddyfile && \
frankenphp version && \
frankenphp build-info
RUN <<EOF
set -e
GOBIN=/usr/local/bin ../../go.sh install -ldflags "-w -s -X 'github.com/caddyserver/caddy/v2.CustomVersion=FrankenPHP $FRANKENPHP_VERSION PHP $PHP_VERSION Caddy' -X 'github.com/caddyserver/caddy/v2.CustomBinaryName=frankenphp' -X 'github.com/caddyserver/caddy/v2/modules/caddyhttp.ServerHeader=FrankenPHP Caddy'" -buildvcs=true
setcap cap_net_bind_service=+ep /usr/local/bin/frankenphp
cp Caddyfile /etc/frankenphp/Caddyfile
frankenphp version
frankenphp build-info
EOF

WORKDIR /go/src/app

Expand All @@ -134,11 +137,17 @@ ENV GODEBUG=cgocheck=0
# copy watcher shared library
COPY --from=builder /usr/local/lib/libwatcher* /usr/local/lib/
# fix for the file watcher on arm
RUN apt-get install -y --no-install-recommends libstdc++6 && \
apt-get clean && \
ldconfig
RUN <<EOF
set -e
apt-get install -y --no-install-recommends libstdc++6
apt-get clean
ldconfig
EOF

COPY --from=builder /usr/local/bin/frankenphp /usr/local/bin/frankenphp
RUN setcap cap_net_bind_service=+ep /usr/local/bin/frankenphp && \
frankenphp version && \
frankenphp build-info
RUN <<EOF
set -e
setcap cap_net_bind_service=+ep /usr/local/bin/frankenphp
frankenphp version
frankenphp build-info
EOF
63 changes: 33 additions & 30 deletions alpine.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,24 @@ ARG TARGETARCH

WORKDIR /app

RUN apk add --no-cache \
ca-certificates \
libcap \
mailcap

RUN set -eux; \
mkdir -p \
/app/public \
/config/caddy \
/data/caddy \
/etc/caddy \
/etc/frankenphp; \
sed -i 's/php/frankenphp run/g' /usr/local/bin/docker-php-entrypoint; \
echo '<?php phpinfo();' > /app/public/index.php
RUN apk add --no-cache ca-certificates libcap mailcap

RUN <<EOF
set -eux
mkdir -p /app/public /config/caddy /data/caddy /etc/caddy /etc/frankenphp
sed -i 's/php/frankenphp run/g' /usr/local/bin/docker-php-entrypoint
echo '<?php phpinfo();' > /app/public/index.php
EOF

COPY --link caddy/frankenphp/Caddyfile /etc/caddy/Caddyfile

RUN ln /etc/caddy/Caddyfile /etc/frankenphp/Caddyfile && \
curl -sSLf \
-o /usr/local/bin/install-php-extensions \
https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions && \
chmod +x /usr/local/bin/install-php-extensions
RUN <<EOF
set -e
ln /etc/caddy/Caddyfile /etc/frankenphp/Caddyfile
curl -sSLf -o /usr/local/bin/install-php-extensions \
https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions
chmod +x /usr/local/bin/install-php-extensions
EOF

CMD ["--config", "/etc/frankenphp/Caddyfile", "--adapter", "caddyfile"]
HEALTHCHECK CMD curl -f http://localhost:2019/metrics || exit 1
Expand Down Expand Up @@ -122,12 +118,13 @@ ENV CGO_CPPFLAGS=$PHP_CPPFLAGS
ENV CGO_LDFLAGS="-lssl -lcrypto -lreadline -largon2 -lcurl -lonig -lz $PHP_LDFLAGS"

WORKDIR /go/src/app/caddy/frankenphp
RUN GOBIN=/usr/local/bin \
../../go.sh install -ldflags "-w -s -extldflags '-Wl,-z,stack-size=0x80000' -X 'github.com/caddyserver/caddy/v2.CustomVersion=FrankenPHP $FRANKENPHP_VERSION PHP $PHP_VERSION Caddy' -X 'github.com/caddyserver/caddy/v2.CustomBinaryName=frankenphp' -X 'github.com/caddyserver/caddy/v2/modules/caddyhttp.ServerHeader=FrankenPHP Caddy'" -buildvcs=true && \
setcap cap_net_bind_service=+ep /usr/local/bin/frankenphp && \
([ -z "${NO_COMPRESS}" ] && upx --best /usr/local/bin/frankenphp || true) && \
frankenphp version && \
frankenphp build-info
RUN <<EOF
GOBIN=/usr/local/bin ../../go.sh install -ldflags "-w -s -extldflags '-Wl,-z,stack-size=0x80000' -X 'github.com/caddyserver/caddy/v2.CustomVersion=FrankenPHP $FRANKENPHP_VERSION PHP $PHP_VERSION Caddy' -X 'github.com/caddyserver/caddy/v2.CustomBinaryName=frankenphp' -X 'github.com/caddyserver/caddy/v2/modules/caddyhttp.ServerHeader=FrankenPHP Caddy'" -buildvcs=true
setcap cap_net_bind_service=+ep /usr/local/bin/frankenphp
[ -z "${NO_COMPRESS}" ] && upx --best /usr/local/bin/frankenphp || true
frankenphp version
frankenphp build-info
EOF

WORKDIR /go/src/app

Expand All @@ -138,10 +135,16 @@ ENV GODEBUG=cgocheck=0

# copy watcher shared library (libgcc and libstdc++ are needed for the watcher)
COPY --from=builder /usr/local/lib/libwatcher* /usr/local/lib/
RUN apk add --no-cache libstdc++ && \
ldconfig /usr/local/lib
RUN <<EOF
set -e
apk add --no-cache libstdc++
ldconfig /usr/local/lib
EOF

COPY --from=builder /usr/local/bin/frankenphp /usr/local/bin/frankenphp
RUN setcap cap_net_bind_service=+ep /usr/local/bin/frankenphp && \
frankenphp version && \
frankenphp build-info
RUN <<EOF
set -e
setcap cap_net_bind_service=+ep /usr/local/bin/frankenphp
frankenphp version
frankenphp build-info
EOF
61 changes: 33 additions & 28 deletions dev-alpine.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ ENV PHPIZE_DEPS="\

SHELL ["/bin/ash", "-eo", "pipefail", "-c"]

RUN apk add --no-cache \
# hadolint ignore=SC2086
RUN <<EOF
apk add --no-cache \
$PHPIZE_DEPS \
argon2-dev \
brotli-dev \
Expand All @@ -32,10 +34,8 @@ RUN apk add --no-cache \
zlib-dev \
bison \
nss-tools \
# file watcher \
libstdc++ \
linux-headers \
# Dev tools \
git \
clang \
cmake \
Expand All @@ -44,36 +44,41 @@ RUN apk add --no-cache \
valgrind \
neovim \
zsh \
libtool && \
echo 'set auto-load safe-path /' > /root/.gdbinit
libtool
echo 'set auto-load safe-path /' > /root/.gdbinit
EOF

WORKDIR /usr/local/src/php
RUN git clone --branch=PHP-8.5 https://github.com/php/php-src.git . && \
# --enable-embed is necessary to generate libphp.so, but we don't use this SAPI directly
./buildconf --force && \
EXTENSION_DIR=/usr/lib/frankenphp/modules ./configure \
--enable-embed \
--enable-zts \
--disable-zend-signals \
--enable-zend-max-execution-timers \
--with-config-file-path=/etc/frankenphp/php.ini \
--with-config-file-scan-dir=/etc/frankenphp/php.d \
--enable-debug && \
make -j"$(nproc)" && \
make install && \
ldconfig /etc/ld.so.conf.d && \
mkdir -p /etc/frankenphp/php.d && \
cp php.ini-development /etc/frankenphp/php.ini && \
echo "zend_extension=opcache.so" >> /etc/frankenphp/php.ini && \
echo "opcache.enable=1" >> /etc/frankenphp/php.ini && \
php --version
RUN <<EOF
git clone --branch=PHP-8.5 https://github.com/php/php-src.git .
# --enable-embed is necessary to generate libphp.so, but we don't use this SAPI directly
./buildconf --force
EXTENSION_DIR=/usr/lib/frankenphp/modules ./configure \
--enable-embed \
--enable-zts \
--disable-zend-signals \
--enable-zend-max-execution-timers \
--with-config-file-path=/etc/frankenphp/php.ini \
--with-config-file-scan-dir=/etc/frankenphp/php.d \
--enable-debug
make -j"$(nproc)"
make install
ldconfig /etc/ld.so.conf.d
mkdir -p /etc/frankenphp/php.d
cp php.ini-development /etc/frankenphp/php.ini
echo "zend_extension=opcache.so" >> /etc/frankenphp/php.ini
echo "opcache.enable=1" >> /etc/frankenphp/php.ini
php --version
EOF

# Install e-dant/watcher (necessary for file watching)
WORKDIR /usr/local/src/watcher
RUN git clone https://github.com/e-dant/watcher . && \
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release && \
cmake --build build/ && \
cmake --install build
RUN <<EOF
git clone https://github.com/e-dant/watcher .
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build/
cmake --install build
EOF

WORKDIR /go/src/app
COPY . .
Expand Down
75 changes: 41 additions & 34 deletions dev.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ ENV PHPIZE_DEPS="\

SHELL ["/bin/bash", "-o", "pipefail", "-c"]

# hadolint ignore=DL3009
RUN apt-get update && \
apt-get -y --no-install-recommends install \
# hadolint ignore=DL3009,SC2086
RUN <<EOF
set -e
apt-get update
apt-get -y --no-install-recommends install \
$PHPIZE_DEPS \
libargon2-dev \
libbrotli-dev \
Expand All @@ -34,7 +36,6 @@ RUN apt-get update && \
zlib1g-dev \
bison \
libnss3-tools \
# Dev tools \
git \
clang \
cmake \
Expand All @@ -43,41 +44,47 @@ RUN apt-get update && \
valgrind \
neovim \
zsh \
libtool-bin && \
echo 'set auto-load safe-path /' > /root/.gdbinit && \
echo '* soft core unlimited' >> /etc/security/limits.conf \
&& \
apt-get clean
libtool-bin
echo 'set auto-load safe-path /' > /root/.gdbinit
echo '* soft core unlimited' >> /etc/security/limits.conf
apt-get clean
EOF

WORKDIR /usr/local/src/php
RUN git clone --branch=PHP-8.5 https://github.com/php/php-src.git . && \
# --enable-embed is only necessary to generate libphp.so, we don't use this SAPI directly
./buildconf --force && \
EXTENSION_DIR=/usr/lib/frankenphp/modules ./configure \
--enable-embed \
--enable-zts \
--disable-zend-signals \
--enable-zend-max-execution-timers \
--with-config-file-path=/etc/frankenphp/php.ini \
--with-config-file-scan-dir=/etc/frankenphp/php.d \
--enable-debug && \
make -j"$(nproc)" && \
make install && \
ldconfig && \
mkdir -p /etc/frankenphp/php.d && \
cp php.ini-development /etc/frankenphp/php.ini && \
echo "zend_extension=opcache.so" >> /etc/frankenphp/php.ini && \
echo "opcache.enable=1" >> /etc/frankenphp/php.ini && \
php --version
RUN <<EOF
set -e
git clone --branch=PHP-8.5 https://github.com/php/php-src.git .
# --enable-embed is only necessary to generate libphp.so, we don't use this SAPI directly
./buildconf --force
EXTENSION_DIR=/usr/lib/frankenphp/modules ./configure \
--enable-embed \
--enable-zts \
--disable-zend-signals \
--enable-zend-max-execution-timers \
--with-config-file-path=/etc/frankenphp/php.ini \
--with-config-file-scan-dir=/etc/frankenphp/php.d \
--enable-debug
make -j"$(nproc)"
make install
ldconfig
mkdir -p /etc/frankenphp/php.d
cp php.ini-development /etc/frankenphp/php.ini
echo "zend_extension=opcache.so" >> /etc/frankenphp/php.ini
echo "opcache.enable=1" >> /etc/frankenphp/php.ini
php --version
EOF

# Install e-dant/watcher (necessary for file watching)
WORKDIR /usr/local/src/watcher
RUN git clone https://github.com/e-dant/watcher . && \
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release && \
cmake --build build/ && \
cmake --install build && \
cp build/libwatcher-c.so /usr/local/lib/libwatcher-c.so && \
ldconfig
RUN <<EOF
set -e
git clone https://github.com/e-dant/watcher .
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build/
cmake --install build
cp build/libwatcher-c.so /usr/local/lib/libwatcher-c.so
ldconfig
EOF

WORKDIR /go/src/app
COPY --link . ./
Expand Down
Loading
Loading