Skip to content

Commit 49e98cc

Browse files
authored
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
1 parent c93729e commit 49e98cc

11 files changed

+101
-90
lines changed

.editorconfig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
root = true
2+
3+
[*]
4+
end_of_line = lf
5+
insert_final_newline = true
6+
7+
[*.sh]
8+
indent_style = tab
9+
tab_width = 4
10+
11+
[*.Dockerfile]
12+
indent_style = tab
13+
tab_width = 4

alpine.Dockerfile

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,12 @@ ENV GOTOOLCHAIN=local
6666
RUN apk add --no-cache --virtual .build-deps \
6767
$PHPIZE_DEPS \
6868
argon2-dev \
69-
# Needed for the custom Go build
69+
# Needed for the custom Go build \
7070
bash \
7171
brotli-dev \
7272
coreutils \
7373
curl-dev \
74-
# Needed for the custom Go build
74+
# Needed for the custom Go build \
7575
git \
7676
gnu-libiconv-dev \
7777
libsodium-dev \
@@ -89,20 +89,20 @@ RUN apk add --no-cache --virtual .build-deps \
8989
# Install e-dant/watcher (necessary for file watching)
9090
WORKDIR /usr/local/src/watcher
9191
RUN --mount=type=secret,id=github-token \
92-
if [ -f /run/secrets/github-token ] && [ -s /run/secrets/github-token ]; then \
93-
curl -s -H "Authorization: Bearer $(cat /run/secrets/github-token)" https://api.github.com/repos/e-dant/watcher/releases/latest; \
94-
else \
95-
curl -s https://api.github.com/repos/e-dant/watcher/releases/latest; \
96-
fi | \
97-
grep tarball_url | \
98-
awk '{ print $2 }' | \
99-
sed 's/,$//' | \
100-
sed 's/"//g' | \
101-
xargs curl -L | \
102-
tar xz --strip-components 1 && \
103-
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release && \
104-
cmake --build build && \
105-
cmake --install build
92+
if [ -f /run/secrets/github-token ] && [ -s /run/secrets/github-token ]; then \
93+
curl -s -H "Authorization: Bearer $(cat /run/secrets/github-token)" https://api.github.com/repos/e-dant/watcher/releases/latest; \
94+
else \
95+
curl -s https://api.github.com/repos/e-dant/watcher/releases/latest; \
96+
fi | \
97+
grep tarball_url | \
98+
awk '{ print $2 }' | \
99+
sed 's/,$//' | \
100+
sed 's/"//g' | \
101+
xargs curl -L | \
102+
tar xz --strip-components 1 && \
103+
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release && \
104+
cmake --build build && \
105+
cmake --install build
106106

107107
WORKDIR /go/src/app
108108

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

124124
WORKDIR /go/src/app/caddy/frankenphp
125125
RUN GOBIN=/usr/local/bin \
126-
../../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 && \
126+
../../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 && \
127127
setcap cap_net_bind_service=+ep /usr/local/bin/frankenphp && \
128128
([ -z "${NO_COMPRESS}" ] && upx --best /usr/local/bin/frankenphp || true) && \
129129
frankenphp version && \

build-static.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,11 @@ ${spcCommand} download --with-php="${PHP_VERSION}" --for-extensions="${PHP_EXTEN
206206
# shellcheck disable=SC2086
207207
FRANKENPHP_SOURCE_DIR=${CURRENT_DIR} ${spcCommand} build --enable-zts --build-embed --build-frankenphp ${SPC_OPT_BUILD_ARGS} "${PHP_EXTENSIONS}" --with-libs="${PHP_EXTENSION_LIBS}"
208208

209+
if [ -n "$CI" ]; then
210+
rm -rf ./downloads
211+
rm -rf ./source
212+
fi
213+
209214
cd ../..
210215

211216
bin="dist/frankenphp-${os}-${arch}"

caddy/caddy_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ func TestPHPServerDirective(t *testing.T) {
407407
`, "caddyfile")
408408

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

dev-alpine.Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ RUN apk add --no-cache \
3232
zlib-dev \
3333
bison \
3434
nss-tools \
35-
# file watcher
35+
# file watcher \
3636
libstdc++ \
3737
linux-headers \
3838
# Dev tools \
@@ -49,7 +49,7 @@ RUN apk add --no-cache \
4949

5050
WORKDIR /usr/local/src/php
5151
RUN git clone --branch=PHP-8.4 https://github.com/php/php-src.git . && \
52-
# --enable-embed is only necessary to generate libphp.so, we don't use this SAPI directly
52+
# --enable-embed is necessary to generate libphp.so, but we don't use this SAPI directly
5353
./buildconf --force && \
5454
EXTENSION_DIR=/usr/lib/frankenphp/modules ./configure \
5555
--enable-embed \
@@ -71,7 +71,7 @@ RUN git clone --branch=PHP-8.4 https://github.com/php/php-src.git . && \
7171
# Install e-dant/watcher (necessary for file watching)
7272
WORKDIR /usr/local/src/watcher
7373
RUN git clone https://github.com/e-dant/watcher . && \
74-
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release && \
74+
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release && \
7575
cmake --build build/ && \
7676
cmake --install build
7777

static-builder-gnu.Dockerfile

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -142,15 +142,15 @@ RUN if [ -n "${BUILD_PACKAGES}" ]; then \
142142
rpm-build \
143143
sudo \
144144
zlib-devel && \
145-
curl -o ruby.tar.gz -fsSL https://cache.ruby-lang.org/pub/ruby/3.4/ruby-3.4.4.tar.gz && \
146-
tar -xzf ruby.tar.gz && \
147-
cd ruby-* && \
148-
./configure --without-baseruby && \
149-
make && \
150-
make install && \
151-
cd .. && \
152-
rm -rf ruby* && \
153-
gem install fpm; \
145+
curl -o ruby.tar.gz -fsSL https://cache.ruby-lang.org/pub/ruby/3.4/ruby-3.4.4.tar.gz && \
146+
tar -xzf ruby.tar.gz && \
147+
cd ruby-* && \
148+
./configure --without-baseruby && \
149+
make && \
150+
make install && \
151+
cd .. && \
152+
rm -rf ruby* && \
153+
gem install fpm; \
154154
fi
155155

156156
WORKDIR /go/src/app
@@ -167,9 +167,4 @@ COPY --link caddy caddy
167167
COPY --link internal internal
168168
COPY --link package package
169169

170-
RUN --mount=type=secret,id=github-token \
171-
GITHUB_TOKEN=$(cat /run/secrets/github-token) ./build-static.sh && \
172-
if [ -n "${BUILD_PACKAGES}" ]; then \
173-
./build-packages.sh; \
174-
fi; \
175-
rm -Rf dist/static-php-cli/source/*
170+
RUN --mount=type=secret,id=github-token GITHUB_TOKEN=$(cat /run/secrets/github-token) ./build-static.sh

static-builder-musl.Dockerfile

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,4 @@ ENV SPC_OPT_BUILD_ARGS='--with-config-file-path=/etc/frankenphp --with-config-fi
103103
ENV SPC_REL_TYPE='binary'
104104
ENV EXTENSION_DIR='/usr/lib/frankenphp/modules'
105105

106-
RUN --mount=type=secret,id=github-token \
107-
GITHUB_TOKEN=$(cat /run/secrets/github-token) ./build-static.sh && \
108-
rm -Rf dist/static-php-cli/source/*
106+
RUN --mount=type=secret,id=github-token GITHUB_TOKEN=$(cat /run/secrets/github-token) ./build-static.sh

testdata/connectionStatusLog.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
<?php
2-
3-
ignore_user_abort(true);
4-
5-
require_once __DIR__.'/_executor.php';
6-
7-
return function () {
8-
if($_GET['finish'] ?? false) {
9-
frankenphp_finish_request();
10-
}
11-
12-
echo 'hi';
13-
flush();
14-
$status = (string) connection_status();
15-
error_log("request {$_GET['i']}: " . $status);
16-
};
1+
<?php
2+
3+
ignore_user_abort(true);
4+
5+
require_once __DIR__.'/_executor.php';
6+
7+
return function () {
8+
if($_GET['finish'] ?? false) {
9+
frankenphp_finish_request();
10+
}
11+
12+
echo 'hi';
13+
flush();
14+
$status = (string) connection_status();
15+
error_log("request {$_GET['i']}: " . $status);
16+
};

testdata/hello.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Hello
1+
Hello

testdata/server-all-vars-ordered.php

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,38 @@
22

33
echo "<pre>\n";
44
foreach ([
5-
'CONTENT_LENGTH',
6-
'HTTP_CONTENT_LENGTH',
7-
'CONTENT_TYPE',
8-
'HTTP_CONTENT_TYPE',
9-
'HTTP_SPECIAL_CHARS',
10-
'DOCUMENT_ROOT',
11-
'DOCUMENT_URI',
12-
'GATEWAY_INTERFACE',
13-
'HTTP_HOST',
14-
'HTTPS',
15-
'PATH_INFO',
16-
'DOCUMENT_ROOT',
17-
'REMOTE_ADDR',
18-
'PHP_SELF',
19-
'REMOTE_HOST',
20-
'REQUEST_SCHEME',
21-
'SCRIPT_FILENAME',
22-
'SCRIPT_NAME',
23-
'SERVER_NAME',
24-
'SERVER_PORT',
25-
'SERVER_PROTOCOL',
26-
'SERVER_SOFTWARE',
27-
'SSL_PROTOCOL',
28-
'AUTH_TYPE',
29-
'REMOTE_IDENT',
30-
'PATH_TRANSLATED',
31-
'QUERY_STRING',
32-
'REMOTE_USER',
33-
'REQUEST_METHOD',
34-
'REQUEST_URI',
35-
'HTTP_X_EMPTY_HEADER',
36-
] as $name) {
5+
'CONTENT_LENGTH',
6+
'HTTP_CONTENT_LENGTH',
7+
'CONTENT_TYPE',
8+
'HTTP_CONTENT_TYPE',
9+
'HTTP_SPECIAL_CHARS',
10+
'DOCUMENT_ROOT',
11+
'DOCUMENT_URI',
12+
'GATEWAY_INTERFACE',
13+
'HTTP_HOST',
14+
'HTTPS',
15+
'PATH_INFO',
16+
'DOCUMENT_ROOT',
17+
'REMOTE_ADDR',
18+
'PHP_SELF',
19+
'REMOTE_HOST',
20+
'REQUEST_SCHEME',
21+
'SCRIPT_FILENAME',
22+
'SCRIPT_NAME',
23+
'SERVER_NAME',
24+
'SERVER_PORT',
25+
'SERVER_PROTOCOL',
26+
'SERVER_SOFTWARE',
27+
'SSL_PROTOCOL',
28+
'AUTH_TYPE',
29+
'REMOTE_IDENT',
30+
'PATH_TRANSLATED',
31+
'QUERY_STRING',
32+
'REMOTE_USER',
33+
'REQUEST_METHOD',
34+
'REQUEST_URI',
35+
'HTTP_X_EMPTY_HEADER',
36+
] as $name) {
3737
echo "$name:" . $_SERVER[$name] . "\n";
3838
}
39-
echo "</pre>";
39+
echo "</pre>\n";

0 commit comments

Comments
 (0)