delete source/downloads after building in script, add .editorconfig (#2000)

* delete source/downloads after building in script, not in dockerfile

* add editorconfig

* eol

* cs fix

* added \n there

* we expect Hello\n

* Change tab width for shell scripts to 4 spaces

* bring back embed comment
This commit is contained in:
Marc
2025-11-20 11:49:09 +01:00
committed by GitHub
parent c93729e136
commit 49e98cc8d6
11 changed files with 101 additions and 90 deletions

13
.editorconfig Normal file
View File

@@ -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

View File

@@ -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 \
@@ -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
@@ -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 && \

View File

@@ -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}"

View File

@@ -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)")
}

View File

@@ -32,7 +32,7 @@ RUN apk add --no-cache \
zlib-dev \
bison \
nss-tools \
# file watcher
# file watcher \
libstdc++ \
linux-headers \
# Dev tools \
@@ -49,7 +49,7 @@ 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
# --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 \
@@ -71,7 +71,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

View File

@@ -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
@@ -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; \
rm -Rf dist/static-php-cli/source/*
RUN --mount=type=secret,id=github-token GITHUB_TOKEN=$(cat /run/secrets/github-token) ./build-static.sh

View File

@@ -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

View File

@@ -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
testdata/hello.txt vendored
View File

@@ -1 +1 @@
Hello
Hello

View File

@@ -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";

View File

@@ -30,4 +30,4 @@ REMOTE_USER:user
REQUEST_METHOD:POST
REQUEST_URI:/original-path?specialChars=%3E\x00%00</>
HTTP_X_EMPTY_HEADER:
</pre>
</pre>