SIGN IN SIGN UP
# syntax=docker/dockerfile:1
#checkov:skip=CKV_DOCKER_2
#checkov:skip=CKV_DOCKER_3
FROM centos:7
ARG FRANKENPHP_VERSION=''
ENV FRANKENPHP_VERSION=${FRANKENPHP_VERSION}
ARG PHP_VERSION=''
ENV PHP_VERSION=${PHP_VERSION}
# args passed to static-php-cli
ARG PHP_EXTENSIONS=''
ARG PHP_EXTENSION_LIBS=''
2025-12-15 20:13:15 +01:00
ARG SPC_OPT_BUILD_ARGS
# args passed to xcaddy
2025-12-15 20:13:15 +01:00
ARG XCADDY_ARGS='--with github.com/dunglas/caddy-cbrotli --with github.com/dunglas/mercure/caddy --with github.com/dunglas/vulcain/caddy'
ENV SPC_CMD_VAR_FRANKENPHP_XCADDY_MODULES="${XCADDY_ARGS}"
ARG CLEAN=''
ARG EMBED=''
ARG DEBUG_SYMBOLS=''
ARG MIMALLOC=''
ARG NO_COMPRESS=''
# Go
ARG GO_VERSION
2025-05-11 22:30:19 +02:00
ENV GOTOOLCHAIN=local
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
# Pass through CI environment flag so build-static.sh can detect CI context
ARG CI
ENV CI=${CI}
# labels, same as static-builder.Dockerfile
LABEL org.opencontainers.image.title=FrankenPHP
LABEL org.opencontainers.image.description="The modern PHP app server"
LABEL org.opencontainers.image.url=https://frankenphp.dev
LABEL org.opencontainers.image.source=https://github.com/php/frankenphp
LABEL org.opencontainers.image.licenses=MIT
LABEL org.opencontainers.image.vendor="Kévin Dunglas"
# yum update
RUN sed -i 's/mirror.centos.org/vault.centos.org/g' /etc/yum.repos.d/*.repo && \
sed -i 's/^#.*baseurl=http/baseurl=http/g' /etc/yum.repos.d/*.repo && \
sed -i 's/^mirrorlist=http/#mirrorlist=http/g' /etc/yum.repos.d/*.repo && \
yum clean all && \
yum makecache && \
yum update -y && \
yum install -y centos-release-scl
# different arch for different scl repo
RUN if [ "$(uname -m)" = "aarch64" ]; then \
sed -i 's|mirror.centos.org/centos|vault.centos.org/altarch|g' /etc/yum.repos.d/CentOS-SCLo-scl-rh.repo ; \
sed -i 's|mirror.centos.org/centos|vault.centos.org/altarch|g' /etc/yum.repos.d/CentOS-SCLo-scl.repo ; \
sed -i 's/^#.*baseurl=http/baseurl=http/g' /etc/yum.repos.d/*.repo ; \
sed -i 's/^mirrorlist=http/#mirrorlist=http/g' /etc/yum.repos.d/*.repo ; \
else \
sed -i 's/mirror.centos.org/vault.centos.org/g' /etc/yum.repos.d/*.repo ; \
sed -i 's/^#.*baseurl=http/baseurl=http/g' /etc/yum.repos.d/*.repo ; \
sed -i 's/^mirrorlist=http/#mirrorlist=http/g' /etc/yum.repos.d/*.repo ; \
fi; \
yum update -y && \
yum install -y devtoolset-10-gcc-* && \
echo "source scl_source enable devtoolset-10" >> /etc/bashrc && \
source /etc/bashrc
# install build essentials
RUN yum install -y \
perl \
make \
bison \
flex \
git \
autoconf \
automake \
tar \
unzip \
gzip \
gcc \
bzip2 \
patch \
xz \
libtool \
perl-IPC-Cmd ; \
curl -o make.tar.gz -fsSL https://ftp.gnu.org/gnu/make/make-4.4.tar.gz && \
tar -zxvf make.tar.gz && \
cd make-* && \
./configure && \
make && \
make install && \
ln -sf /usr/local/bin/make /usr/bin/make && \
cd .. && \
rm -Rf make* && \
curl -o cmake.tar.gz -fsSL https://github.com/Kitware/CMake/releases/download/v4.1.2/cmake-4.1.2-linux-$(uname -m).tar.gz && \
mkdir /cmake && \
tar -xzf cmake.tar.gz -C /cmake --strip-components 1 && \
rm cmake.tar.gz && \
curl -fsSL -o patchelf.tar.gz https://github.com/NixOS/patchelf/releases/download/0.18.0/patchelf-0.18.0-$(uname -m).tar.gz && \
mkdir -p /patchelf && \
tar -xzf patchelf.tar.gz -C /patchelf --strip-components=1 && \
cp /patchelf/bin/patchelf /usr/bin/ && \
rm patchelf.tar.gz && \
if [ "$(uname -m)" = "aarch64" ]; then \
GO_ARCH="arm64" ; \
else \
GO_ARCH="amd64" ; \
fi; \
curl -o /usr/local/bin/jq -fsSL https://github.com/jqlang/jq/releases/download/jq-1.7.1/jq-linux-${GO_ARCH} && \
chmod +x /usr/local/bin/jq && \
curl -o go.tar.gz -fsSL https://go.dev/dl/$(curl -fsS https://go.dev/dl/?mode=json | jq -r "first(first(.[] | select(.stable and (.version | startswith(\"go${GO_VERSION}\")))).files[] | select(.os == \"linux\" and (.kind == \"archive\") and (.arch == \"${GO_ARCH}\"))).filename") && \
rm -rf /usr/local/go && \
tar -C /usr/local -xzf go.tar.gz && \
rm go.tar.gz && \
/usr/local/go/bin/go install github.com/caddyserver/xcaddy/cmd/xcaddy@latest
ENV PATH="/opt/rh/devtoolset-10/root/usr/bin:/cmake/bin:/usr/local/go/bin:$PATH"
2025-05-11 22:30:19 +02:00
# Apply GNU mode
ENV SPC_DEFAULT_C_FLAGS='-fPIE -fPIC -O3'
ENV SPC_LIBC='glibc'
ENV SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS_PROGRAM='-Wl,-O3 -pie'
ENV SPC_CMD_VAR_PHP_MAKE_EXTRA_LIBS='-ldl -lpthread -lm -lresolv -lutil -lrt'
2025-12-15 20:13:15 +01:00
# Keep default config paths and append any externally provided SPC_OPT_BUILD_ARGS (e.g., from CI)
ENV SPC_OPT_BUILD_ARGS="--with-config-file-path=/etc/frankenphp --with-config-file-scan-dir=/etc/frankenphp/php.d ${SPC_OPT_BUILD_ARGS}"
ENV SPC_REL_TYPE='binary'
ci: build .rpm and .deb packages (#1497) * add ./create-rpm.sh file to build a "frankenphp" rpm package * also build a deb package * renamed to build-packages * linter... * add depends * linter again? * linter number 3 * linter number 4 * set default locations for ini file, conf files and extensions * set unified path for modules that should be ok on all dists * add default content into "package" folder * make file executable * worker is in public folder * what on earth did I do x) * use same FRANKENPHP_VERSION and make sure to let pr's run the rpm generation too (version 0.0.0) to see issues * install ruby, fpm and rpm-build * move to after changing base urls because it would fail with packages not found * ruby 3 build needs gcc 10 * rpm-build is necessary too... * and I forgot to link the package folder * create directories if they don't exist * copy out all frankenphp* files? * lint fix * only copy frankenphp-* files * only copy frankenphp-* files * the .deb file is name frankenphp_1.5.0... - create output folder instead and upload all things inside that will simplify things when later adding xdebug.so and ffi.so * update the last two steps to use the gh-output directory * add post install script to set frankenphp able to bind to port 80 for non-root users * dnf over yum, I think the yum alias was removed in RH 9.5 * newlines * newlines * add text what missing libcap means * copy php.ini-production from php-src, linter, update ruby version * move Caddyfile to /etc/frankenphp/Caddyfile * linter * fix a copy and paste error * better describe fallback to 0.0.0 * linter * copy installation scripts from official caddy packages, change user to frankenphp too * bombombom * make files executable * tabs * linter * linter again * use empty directory for three different destinations instead of keeping three empty local directories * caddy says the file is incorrectly formatted without these spaces * remove wildcard matcher from root directive * Apply suggestions from code review commit suggested changes to preinstall/postinstall scripts Co-authored-by: Kévin Dunglas <kevin@dunglas.fr> * Update dev.Dockerfile Co-authored-by: Kévin Dunglas <kevin@dunglas.fr> * remove misleading comment * update documentation for paths * update documentation for paths some more * fix musl opcache-jit issue * markdown linter * the damn tab * Apply suggestions from code review Co-authored-by: Kévin Dunglas <kevin@dunglas.fr> * drop dev.Dockerfile php location from config.md * add php config note to CONTRIBUTING.md * dashes instead of asterisks in chinese docs * fix package building * create frankenphp user in case it doesn't exist for deb packages * create users if they don't exist, delete them again if they didn't exist * satisfy linter * create the user with the same commands as the postinst/preinstall scripts * Removes toolchain requirements. * trigger * Removes explicit calls to go get * trigger * setcap by default * simplify example project * bring page more in line with the caddy / apache / nginx default page * update to html 5 * oopsies * revert style to original * remove https:// (caddy uses http:// on RHEL, :80 on Debian) --------- Co-authored-by: Kévin Dunglas <kevin@dunglas.fr> Co-authored-by: Alliballibaba <alliballibaba@gmail.com>
2025-05-14 12:33:05 +07:00
ENV EXTENSION_DIR='/usr/lib/frankenphp/modules'
# not sure if this is needed
ENV COMPOSER_ALLOW_SUPERUSER=1
WORKDIR /go/src/app
COPY go.mod go.sum ./
RUN go mod download
WORKDIR /go/src/app/caddy
COPY caddy/go.mod caddy/go.sum ./
2025-05-11 22:30:19 +02:00
RUN go mod download
WORKDIR /go/src/app
COPY --link *.* ./
COPY --link caddy caddy
COPY --link internal internal
ci: build .rpm and .deb packages (#1497) * add ./create-rpm.sh file to build a "frankenphp" rpm package * also build a deb package * renamed to build-packages * linter... * add depends * linter again? * linter number 3 * linter number 4 * set default locations for ini file, conf files and extensions * set unified path for modules that should be ok on all dists * add default content into "package" folder * make file executable * worker is in public folder * what on earth did I do x) * use same FRANKENPHP_VERSION and make sure to let pr's run the rpm generation too (version 0.0.0) to see issues * install ruby, fpm and rpm-build * move to after changing base urls because it would fail with packages not found * ruby 3 build needs gcc 10 * rpm-build is necessary too... * and I forgot to link the package folder * create directories if they don't exist * copy out all frankenphp* files? * lint fix * only copy frankenphp-* files * only copy frankenphp-* files * the .deb file is name frankenphp_1.5.0... - create output folder instead and upload all things inside that will simplify things when later adding xdebug.so and ffi.so * update the last two steps to use the gh-output directory * add post install script to set frankenphp able to bind to port 80 for non-root users * dnf over yum, I think the yum alias was removed in RH 9.5 * newlines * newlines * add text what missing libcap means * copy php.ini-production from php-src, linter, update ruby version * move Caddyfile to /etc/frankenphp/Caddyfile * linter * fix a copy and paste error * better describe fallback to 0.0.0 * linter * copy installation scripts from official caddy packages, change user to frankenphp too * bombombom * make files executable * tabs * linter * linter again * use empty directory for three different destinations instead of keeping three empty local directories * caddy says the file is incorrectly formatted without these spaces * remove wildcard matcher from root directive * Apply suggestions from code review commit suggested changes to preinstall/postinstall scripts Co-authored-by: Kévin Dunglas <kevin@dunglas.fr> * Update dev.Dockerfile Co-authored-by: Kévin Dunglas <kevin@dunglas.fr> * remove misleading comment * update documentation for paths * update documentation for paths some more * fix musl opcache-jit issue * markdown linter * the damn tab * Apply suggestions from code review Co-authored-by: Kévin Dunglas <kevin@dunglas.fr> * drop dev.Dockerfile php location from config.md * add php config note to CONTRIBUTING.md * dashes instead of asterisks in chinese docs * fix package building * create frankenphp user in case it doesn't exist for deb packages * create users if they don't exist, delete them again if they didn't exist * satisfy linter * create the user with the same commands as the postinst/preinstall scripts * Removes toolchain requirements. * trigger * Removes explicit calls to go get * trigger * setcap by default * simplify example project * bring page more in line with the caddy / apache / nginx default page * update to html 5 * oopsies * revert style to original * remove https:// (caddy uses http:// on RHEL, :80 on Debian) --------- Co-authored-by: Kévin Dunglas <kevin@dunglas.fr> Co-authored-by: Alliballibaba <alliballibaba@gmail.com>
2025-05-14 12:33:05 +07:00
COPY --link package package
RUN --mount=type=secret,id=github-token GITHUB_TOKEN=$(cat /run/secrets/github-token) ./build-static.sh