Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 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
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true

[*.sh]
indent_style = tab
tab_width = 4

[*.Dockerfile]
indent_style = tab
tab_width = 4
34 changes: 17 additions & 17 deletions alpine.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ ENV GOTOOLCHAIN=local
RUN apk add --no-cache --virtual .build-deps \
$PHPIZE_DEPS \
argon2-dev \
# Needed for the custom Go build
# Needed for the custom Go build \
bash \
brotli-dev \
coreutils \
curl-dev \
# Needed for the custom Go build
# Needed for the custom Go build \
git \
gnu-libiconv-dev \
libsodium-dev \
Expand All @@ -89,20 +89,20 @@ RUN apk add --no-cache --virtual .build-deps \
# Install e-dant/watcher (necessary for file watching)
WORKDIR /usr/local/src/watcher
RUN --mount=type=secret,id=github-token \
if [ -f /run/secrets/github-token ] && [ -s /run/secrets/github-token ]; then \
curl -s -H "Authorization: Bearer $(cat /run/secrets/github-token)" https://api.github.com/repos/e-dant/watcher/releases/latest; \
else \
curl -s https://api.github.com/repos/e-dant/watcher/releases/latest; \
fi | \
grep tarball_url | \
awk '{ print $2 }' | \
sed 's/,$//' | \
sed 's/"//g' | \
xargs curl -L | \
tar xz --strip-components 1 && \
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release && \
cmake --build build && \
cmake --install build
if [ -f /run/secrets/github-token ] && [ -s /run/secrets/github-token ]; then \
curl -s -H "Authorization: Bearer $(cat /run/secrets/github-token)" https://api.github.com/repos/e-dant/watcher/releases/latest; \
else \
curl -s https://api.github.com/repos/e-dant/watcher/releases/latest; \
fi | \
grep tarball_url | \
awk '{ print $2 }' | \
sed 's/,$//' | \
sed 's/"//g' | \
xargs curl -L | \
tar xz --strip-components 1 && \
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release && \
cmake --build build && \
cmake --install build

WORKDIR /go/src/app

Expand All @@ -123,7 +123,7 @@ ENV CGO_LDFLAGS="-lssl -lcrypto -lreadline -largon2 -lcurl -lonig -lz $PHP_LDFLA

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'" -buildvcs=true && \
../../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'" -buildvcs=true && \
setcap cap_net_bind_service=+ep /usr/local/bin/frankenphp && \
([ -z "${NO_COMPRESS}" ] && upx --best /usr/local/bin/frankenphp || true) && \
frankenphp version && \
Expand Down
5 changes: 5 additions & 0 deletions build-static.sh
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,11 @@ ${spcCommand} download --with-php="${PHP_VERSION}" --for-extensions="${PHP_EXTEN
# shellcheck disable=SC2086
FRANKENPHP_SOURCE_DIR=${CURRENT_DIR} ${spcCommand} build --enable-zts --build-embed --build-frankenphp ${SPC_OPT_BUILD_ARGS} "${PHP_EXTENSIONS}" --with-libs="${PHP_EXTENSION_LIBS}"

if [ -n "$CI" ]; then
rm -rf ./downloads
rm -rf ./source
fi

cd ../..

bin="dist/frankenphp-${os}-${arch}"
Expand Down
2 changes: 1 addition & 1 deletion caddy/caddy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ func TestPHPServerDirective(t *testing.T) {
`, "caddyfile")

tester.AssertGetResponse("http://localhost:"+testPort, http.StatusOK, "I am by birth a Genevese (i not set)")
tester.AssertGetResponse("http://localhost:"+testPort+"/hello.txt", http.StatusOK, "Hello")
tester.AssertGetResponse("http://localhost:"+testPort+"/hello.txt", http.StatusOK, "Hello\n")
tester.AssertGetResponse("http://localhost:"+testPort+"/not-found.txt", http.StatusOK, "I am by birth a Genevese (i not set)")
}

Expand Down
5 changes: 2 additions & 3 deletions dev-alpine.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ RUN apk add --no-cache \
zlib-dev \
bison \
nss-tools \
# file watcher
# file watcher \
libstdc++ \
linux-headers \
# Dev tools \
Expand All @@ -49,7 +49,6 @@ RUN apk add --no-cache \

WORKDIR /usr/local/src/php
RUN git clone --branch=PHP-8.4 https://github.com/php/php-src.git . && \
# --enable-embed is only necessary to generate libphp.so, we don't use this SAPI directly
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why removing this comment?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because we use libphp.so embed SAPI directly and therefore directly rely on --enable-embed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment is still relevant. We don't use the embed SAPI, but we need to use this flag to build because it builds libphp as a side effect

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# --enable-embed is only necessary to generate libphp.so, we don't use this SAPI directly
# --enable-embed is necessary to generate libphp.so, but we don't use the SAPI directly

./buildconf --force && \
EXTENSION_DIR=/usr/lib/frankenphp/modules ./configure \
--enable-embed \
Expand All @@ -71,7 +70,7 @@ RUN git clone --branch=PHP-8.4 https://github.com/php/php-src.git . && \
# 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 -S . -B build -DCMAKE_BUILD_TYPE=Release && \
cmake --build build/ && \
cmake --install build

Expand Down
25 changes: 10 additions & 15 deletions static-builder-gnu.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -142,15 +142,15 @@ RUN if [ -n "${BUILD_PACKAGES}" ]; then \
rpm-build \
sudo \
zlib-devel && \
curl -o ruby.tar.gz -fsSL https://cache.ruby-lang.org/pub/ruby/3.4/ruby-3.4.4.tar.gz && \
tar -xzf ruby.tar.gz && \
cd ruby-* && \
./configure --without-baseruby && \
make && \
make install && \
cd .. && \
rm -rf ruby* && \
gem install fpm; \
curl -o ruby.tar.gz -fsSL https://cache.ruby-lang.org/pub/ruby/3.4/ruby-3.4.4.tar.gz && \
tar -xzf ruby.tar.gz && \
cd ruby-* && \
./configure --without-baseruby && \
make && \
make install && \
cd .. && \
rm -rf ruby* && \
gem install fpm; \
fi

WORKDIR /go/src/app
Expand All @@ -167,9 +167,4 @@ COPY --link caddy caddy
COPY --link internal internal
COPY --link package package

RUN --mount=type=secret,id=github-token \
GITHUB_TOKEN=$(cat /run/secrets/github-token) ./build-static.sh && \
if [ -n "${BUILD_PACKAGES}" ]; then \
./build-packages.sh; \
fi; \
Comment on lines -171 to -174
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getting rid of this entirely all together in another PR

rm -Rf dist/static-php-cli/source/*
RUN --mount=type=secret,id=github-token GITHUB_TOKEN=$(cat /run/secrets/github-token) ./build-static.sh
4 changes: 1 addition & 3 deletions static-builder-musl.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,4 @@ ENV SPC_OPT_BUILD_ARGS='--with-config-file-path=/etc/frankenphp --with-config-fi
ENV SPC_REL_TYPE='binary'
ENV EXTENSION_DIR='/usr/lib/frankenphp/modules'

RUN --mount=type=secret,id=github-token \
GITHUB_TOKEN=$(cat /run/secrets/github-token) ./build-static.sh && \
rm -Rf dist/static-php-cli/source/*
RUN --mount=type=secret,id=github-token GITHUB_TOKEN=$(cat /run/secrets/github-token) ./build-static.sh
32 changes: 16 additions & 16 deletions testdata/connectionStatusLog.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<?php
ignore_user_abort(true);
require_once __DIR__.'/_executor.php';
return function () {
if($_GET['finish'] ?? false) {
frankenphp_finish_request();
}
echo 'hi';
flush();
$status = (string) connection_status();
error_log("request {$_GET['i']}: " . $status);
};
<?php

ignore_user_abort(true);

require_once __DIR__.'/_executor.php';

return function () {
if($_GET['finish'] ?? false) {
frankenphp_finish_request();
}

echo 'hi';
flush();
$status = (string) connection_status();
error_log("request {$_GET['i']}: " . $status);
};
2 changes: 1 addition & 1 deletion testdata/hello.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Hello
Hello
66 changes: 33 additions & 33 deletions testdata/server-all-vars-ordered.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,38 @@

echo "<pre>\n";
foreach ([
'CONTENT_LENGTH',
'HTTP_CONTENT_LENGTH',
'CONTENT_TYPE',
'HTTP_CONTENT_TYPE',
'HTTP_SPECIAL_CHARS',
'DOCUMENT_ROOT',
'DOCUMENT_URI',
'GATEWAY_INTERFACE',
'HTTP_HOST',
'HTTPS',
'PATH_INFO',
'DOCUMENT_ROOT',
'REMOTE_ADDR',
'PHP_SELF',
'REMOTE_HOST',
'REQUEST_SCHEME',
'SCRIPT_FILENAME',
'SCRIPT_NAME',
'SERVER_NAME',
'SERVER_PORT',
'SERVER_PROTOCOL',
'SERVER_SOFTWARE',
'SSL_PROTOCOL',
'AUTH_TYPE',
'REMOTE_IDENT',
'PATH_TRANSLATED',
'QUERY_STRING',
'REMOTE_USER',
'REQUEST_METHOD',
'REQUEST_URI',
'HTTP_X_EMPTY_HEADER',
] as $name) {
'CONTENT_LENGTH',
'HTTP_CONTENT_LENGTH',
'CONTENT_TYPE',
'HTTP_CONTENT_TYPE',
'HTTP_SPECIAL_CHARS',
'DOCUMENT_ROOT',
'DOCUMENT_URI',
'GATEWAY_INTERFACE',
'HTTP_HOST',
'HTTPS',
'PATH_INFO',
'DOCUMENT_ROOT',
'REMOTE_ADDR',
'PHP_SELF',
'REMOTE_HOST',
'REQUEST_SCHEME',
'SCRIPT_FILENAME',
'SCRIPT_NAME',
'SERVER_NAME',
'SERVER_PORT',
'SERVER_PROTOCOL',
'SERVER_SOFTWARE',
'SSL_PROTOCOL',
'AUTH_TYPE',
'REMOTE_IDENT',
'PATH_TRANSLATED',
'QUERY_STRING',
'REMOTE_USER',
'REQUEST_METHOD',
'REQUEST_URI',
'HTTP_X_EMPTY_HEADER',
] as $name) {
echo "$name:" . $_SERVER[$name] . "\n";
}
echo "</pre>";
echo "</pre>\n";
2 changes: 1 addition & 1 deletion testdata/server-all-vars-ordered.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ REMOTE_USER:user
REQUEST_METHOD:POST
REQUEST_URI:/original-path?specialChars=%3E\x00%00</>
HTTP_X_EMPTY_HEADER:
</pre>
</pre>
Loading