diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 000000000..ff8d338dc --- /dev/null +++ b/.editorconfig @@ -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 diff --git a/alpine.Dockerfile b/alpine.Dockerfile index c566abbc4..8e4318db4 100644 --- a/alpine.Dockerfile +++ b/alpine.Dockerfile @@ -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 && \ diff --git a/build-static.sh b/build-static.sh index 4c5256de0..a334608ba 100755 --- a/build-static.sh +++ b/build-static.sh @@ -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}" diff --git a/caddy/caddy_test.go b/caddy/caddy_test.go index 7ca641fdd..7cf69bfa5 100644 --- a/caddy/caddy_test.go +++ b/caddy/caddy_test.go @@ -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)") } diff --git a/dev-alpine.Dockerfile b/dev-alpine.Dockerfile index 6bc5a17cc..68184463b 100644 --- a/dev-alpine.Dockerfile +++ b/dev-alpine.Dockerfile @@ -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 diff --git a/static-builder-gnu.Dockerfile b/static-builder-gnu.Dockerfile index dea043b70..7257b12c0 100644 --- a/static-builder-gnu.Dockerfile +++ b/static-builder-gnu.Dockerfile @@ -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 diff --git a/static-builder-musl.Dockerfile b/static-builder-musl.Dockerfile index 8a653d0be..d388a53d6 100644 --- a/static-builder-musl.Dockerfile +++ b/static-builder-musl.Dockerfile @@ -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 diff --git a/testdata/connectionStatusLog.php b/testdata/connectionStatusLog.php index a5568eb77..80e6955dc 100644 --- a/testdata/connectionStatusLog.php +++ b/testdata/connectionStatusLog.php @@ -1,16 +1,16 @@ -\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 ""; \ No newline at end of file +echo "\n"; diff --git a/testdata/server-all-vars-ordered.txt b/testdata/server-all-vars-ordered.txt index 0cd81d4eb..8b963a433 100644 --- a/testdata/server-all-vars-ordered.txt +++ b/testdata/server-all-vars-ordered.txt @@ -30,4 +30,4 @@ REMOTE_USER:user REQUEST_METHOD:POST REQUEST_URI:/original-path?specialChars=%3E\x00%00 HTTP_X_EMPTY_HEADER: - \ No newline at end of file +