Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't get custom modules to build #591

Closed
StephenMiracle opened this issue Feb 23, 2024 · 18 comments · Fixed by #1210
Closed

Can't get custom modules to build #591

StephenMiracle opened this issue Feb 23, 2024 · 18 comments · Fixed by #1210
Labels
bug Something isn't working

Comments

@StephenMiracle
Copy link
Contributor

What happened?

I can't get FrankenPHP to compile with HTTP cache module: https://github.com/caddyserver/cache-handler (or other popular caddy modules)

I'm building a WordPress Docker image where I'm hoping to beat benchmarks and stress tests of the standard WordPress Docker image. I've been using loader.io and FrankenPHP starts to get significantly slower than the standard Apache Docker Image. I believe it is due to some caching. Apache response times for Apache stay consistent no matter the load I throw at it.

I've updated to match the WordPress image defaults as much as possible. I've included & optimized Opcache, but it still gets up to 7-8 seconds when I send 1800 requests to my WordPress image in 1 minute. Comparably, the standard WordPress Apache version takes 450ms consistently.

So I believe it must be something with additional HTTP caching.

--

I'm trying to build FrankenPHP with this module: github.com/caddyserver/cache-handler , but its throwing back C errors that I just can't understand. I've tried other modules but still have similar issues.

I'm attaching the build errors in the log output below.

Thanks! I'm really enjoying this project.

Build Type

Docker (Debian Bookworm)

Worker Mode

No

Operating System

GNU/Linux

CPU Architecture

x86_64

Relevant log output

#11 38.58 go: downloading google.golang.org/appengine v1.6.7
#11 39.04 2024/02/23 15:49:06 [INFO] exec (timeout=0s): /usr/local/go/bin/go build -o /usr/local/bin/frankenphp -ldflags -w -s
#11 60.97 # caddy
#11 60.97 /usr/local/go/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
#11 60.97 /usr/bin/ld: /tmp/go-link-3153015539/000017.o: warning: relocation against `stderr@@GLIBC_2.2.5' in read-only section `.text'
#11 60.97 /usr/bin/ld: /tmp/go-link-3153015539/000009.o: relocation R_X86_64_PC32 against symbol `stderr@@GLIBC_2.2.5' can not be used when making a PDE object; recompile with -fPIE
#11 60.97 /usr/bin/ld: final link failed: bad value
#11 60.97 collect2: error: ld returned 1 exit status
@StephenMiracle StephenMiracle added the bug Something isn't working label Feb 23, 2024
@withinboredom
Copy link
Collaborator

It's hard to say anything without actual details of what you are doing.

IRT WordPress:

WordPress probably can't work in worker mode since it relies on global state. There are ways around that, at least for core, though it's unlikely plugins will work correctly. That basically limits you to cgi-mode, which is still pretty darn fast. I'd have to see your actual setup to get any idea as to what is going on.

I've updated to match the WordPress image defaults as much as possible.

I'd recommend not using those :) they're pretty good though. When I worked at Automattic, I spent quite a bit of time building out an actual "official" image instead of a community one, specifically for Jetpack. We ended up contracting with Bitnami (IIRC). I highly recommend those images as a good starting point. Beyond that, I'd recommend taking a look at vip-go's skeleton repo for some crazy stuff.

IRT load testing:

I've spotted a bug with Go's handling of FIN and FIN_WAIT packets (they can be delayed up to 600ms in my experience, which won't cause any issues for humans or actual traffic, but means most load testing software simply won't fire another request until the previous one closes which makes it seem as though it isn't as fast as it "really" is), but I haven't spent enough time trying to work out what is going on to properly report it. All I can say is that some load-testing tools show really bad performance depending on how they report the throughput. K6 seems to do pretty well in our experience. (IOW, do you measure the time to get all the data, or do you measure the time until the connection is actually closed? Both are useful metrics, one for humans and one for non-humans).

IRT to modules:

I'm trying to build FrankenPHP with this module: github.com/caddyserver/cache-handler , but its throwing back C errors that I just can't understand. I've tried other modules but still have similar issues.

How are you building them? From the looks of that error, some linker flags aren't set properly but should be set in the builder container described in the docs.

@StephenMiracle
Copy link
Contributor Author

Thanks for the feedback. Here's a link to the Dockerfile.

https://github.com/wpeverywhere/wordpress-docker-frankenphp/blob/main/Dockerfile

I did some testing, and I think it is an issue of using "cgo" . I can get FrankenPHP to build without the additional modules and I can get the modules to build without cgo. But, using cgo even breaks when not including FrankenPHP with these modules.

If FrankenPHP continues to need cgo, then it may be good to add a disclaimer in that "custom Cadddy build" section of the site that additional modules need to be compatible with cgo. I'm assuming it has to be used for the C-Thread-Pool package in order to avoid php-fpm.

--

Honestly, is there a big benefit of using FrankenPHP with WordPress than a Caddy server with php-fpm? I can include php-fpm with Caddy inside a single Dockerfile which is a big win. And since WordPress isn't suitable for Workers, then I'm not seeing the benefit... I do think FrankenPHP is likely really great for a sizeable amount of modern PHP projects, but WP may not be a good fit.

@withinboredom
Copy link
Collaborator

withinboredom commented Feb 24, 2024

In the dockerfile, where you set:

XCADDY_GO_BUILD_FLAGS="-ldflags '-w -s'"

Try per the error message you got:

XCADDY_GO_BUILD_FLAGS="-ldflags '-w -s -fPIE'"

I did some testing, and I think it is an issue of using "cgo"

Cgo is the glue between caddy and PHP, PHP is running natively in caddy (similar to apache) and some caddy modules might also be using cgo. Sometimes those modules will have custom compiler/linker flags that need to be set manually in order to compile.

Honestly, is there a big benefit of using FrankenPHP with WordPress than a Caddy server with php-fpm?

Hmm. Maybe. You could literally create a self-executable of your Wordpress installation (that would be possible with the bitnami layout mentioned earlier).

Basically, you just drop "FrankenWP" into a folder with a plugins & content directory and run it. Done. Especially if you used something like https://wordpress.org/plugins/sqlite-database-integration/ (which is maintained by WP btw -- all unit tests run with that so, it is guaranteed to work and be maintained); you don't even need MySQL.

A docker container wouldn't even be needed, just a single executable.

So, yeah, I think there is some serious potential there if you wanted to do something bleeding edge.

@StephenMiracle
Copy link
Contributor Author

I gave it a few more tries to no success with the commands. I did several variations of XCADDY_GO_BUILD_FLAGS="-ldflags '-w -s'" . It couldn't build.

@dunglas , have you been able to compile FrankenPHP with additional caddy modules? It could be helpful to have a list of known modules that work well and require more effort with FrankenPHP. I'd be willing to provide some help with it as well .

--

I ended up just pushing up what I could for now. I'll reconsider working on a self-executable version in upcoming iterations. Its a cool idea.

Thanks again for the feedback.

@dunglas
Copy link
Owner

dunglas commented Feb 25, 2024

@StephenMiracle this looks like a duplicate of #374. Can you try if #374 (comment) fixes your issue?

@StephenMiracle
Copy link
Contributor Author

Nice! That it is. And that did it :)

Here's the full line in my Dockerfile that made it work:

ENV CGO_ENABLED=1 CGO_LDFLAGS=-no-pie XCADDY_SETCAP=1 CGO_LDFLAGS=-pie XCADDY_GO_BUILD_FLAGS='-buildmode=pie -ldflags="-w -s" -trimpath'

@dunglas
Copy link
Owner

dunglas commented Feb 26, 2024

That would be nice to add this to the docs! PR welcome 🤗

@StephenMiracle
Copy link
Contributor Author

Screenshot 2024-03-28 214220

Hey, I wanted to circle back to this one as it came up a bit ago when someone was trying to run the WP image on Rocky Linux arch .

The attached screenshot is what occurs when I try to run the dockerfile with the custom build and pie values.

I was trying to avoid going this route with the Dockerfile by trying to simulate the arm, but it doesn't appear to work in this case.

Anyway, I am unsure what to do with the attached screenshot at this point.

@withinboredom
Copy link
Collaborator

IIRC, this happens when you try to use something incompatible or needs custom build parameters. I could be wrong, it's hard to say without some way to reproduce it.

@MickaelCa
Copy link

Hi!

I'm also trying to build frankenphp with souin, the build pass but I have a crash immedately after the first request.

Caddy running logs
php-1  | frankenphp: Symbol `spl_ce_RuntimeException' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `stderr' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `stderr' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `stderr' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `stderr' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `stderr' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `stderr' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `stderr' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `stderr' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `stderr' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `stderr' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `stderr' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `stderr' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `sapi_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `sapi_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `sapi_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `sapi_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `sapi_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `sapi_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `sapi_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `sapi_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `sapi_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `sapi_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `sapi_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `sapi_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `sapi_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `sapi_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `sapi_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `sapi_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `sapi_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `sapi_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `sapi_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `sapi_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `sapi_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `sapi_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `sapi_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `sapi_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `sapi_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `sapi_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `sapi_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `sapi_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `sapi_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `sapi_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `sapi_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `sapi_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `sapi_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `sapi_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `sapi_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `sapi_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `sapi_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `sapi_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `sapi_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `sapi_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `sapi_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `sapi_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `sapi_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `sapi_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `sapi_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `sapi_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `sapi_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `sapi_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `sapi_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `sapi_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `sapi_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `sapi_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `sapi_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `sapi_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `sapi_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `sapi_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `executor_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `executor_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `executor_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `executor_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `executor_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `executor_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `executor_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `executor_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `executor_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `executor_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `executor_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `executor_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `executor_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `executor_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `executor_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `executor_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `executor_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `executor_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `executor_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `executor_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `executor_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `executor_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `executor_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `executor_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `executor_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `executor_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `executor_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `executor_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `executor_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `executor_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `executor_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `core_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `core_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `core_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `core_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `core_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `core_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `core_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `core_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `core_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `core_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `core_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `core_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `core_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `zend_known_strings' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `module_registry' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `module_registry' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `sapi_module' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `sapi_module' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `sapi_module' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `sapi_module' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `sapi_module' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `sapi_module' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `sapi_module' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `sapi_module' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `sapi_module' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `php_import_environment_variables' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `php_import_environment_variables' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `php_embed_module' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `php_embed_module' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `zend_string_init_interned' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `zend_string_init_interned' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `zend_string_init_interned' causes overflow in R_X86_64_PC32 relocation
php-1  | frankenphp: Symbol `compiler_globals_offset' causes overflow in R_X86_64_PC32 relocation
php-1  | {"level":"info","ts":1712353188.2304914,"msg":"using provided configuration","config_file":"/etc/caddy/Caddyfile","config_adapter":""}
php-1  | {"level":"warn","ts":1712353188.2317178,"msg":"Caddyfile input is not formatted; run 'caddy fmt --overwrite' to fix inconsistencies","adapter":"caddyfile","file":"/etc/caddy/Caddyfile","line":4}
php-1  | {"level":"info","ts":1712353188.2329445,"logger":"admin","msg":"admin endpoint started","address":"localhost:2019","enforce_origin":false,"origins":["//localhost:2019","//[::1]:2019","//127.0.0.1:2019"]}
php-1  | {"level":"info","ts":1712353188.2330763,"logger":"http.auto_https","msg":"server is listening only on the HTTPS port but has no TLS connection policies; adding one to enable TLS","server_name":"srv0","https_port":443}
php-1  | {"level":"info","ts":1712353188.2330844,"logger":"http.auto_https","msg":"enabling automatic HTTP->HTTPS redirects","server_name":"srv0"}
php-1  | {"level":"warn","ts":1712353188.2330916,"logger":"http.auto_https","msg":"server is listening only on the HTTP port, so no automatic HTTPS will be applied to this server","server_name":"srv1","http_port":80}
php-1  | {"level":"info","ts":1712353188.2331293,"logger":"tls.cache.maintenance","msg":"started background certificate maintenance","cache":"0xc000817f00"}
php-1  | {"level":"info","ts":1712353188.235161,"msg":"FrankenPHP started 🐘","php_version":"8.3.4"}
php-1  | {"level":"info","ts":1712353188.2356842,"logger":"tls","msg":"cleaning storage unit","storage":"FileStorage:/data/caddy"}
php-1  | {"level":"info","ts":1712353188.2358146,"logger":"tls","msg":"finished cleaning storage units"}
php-1  | {"level":"warn","ts":1712353188.246113,"logger":"pki.ca.local","msg":"installing root certificate (you might be prompted for password)","path":"storage:pki/authorities/local/root.crt"}
php-1  | {"level":"info","ts":1712353188.2464762,"msg":"warning: \"certutil\" is not available, install \"certutil\" with \"apt install libnss3-tools\" or \"yum install nss-tools\" and try again"}
php-1  | {"level":"info","ts":1712353188.2464828,"msg":"define JAVA_HOME environment variable to use the Java trust"}
php-1  | {"level":"error","ts":1712353188.2472742,"logger":"pki.ca.local","msg":"failed to install root certificate","error":"failed to execute tee: exit status 1","certificate_file":"storage:pki/authorities/local/root.crt"}
php-1  | {"level":"info","ts":1712353188.2474,"logger":"http.log","msg":"server running","name":"srv1","protocols":["h1","h2","h3"]}
php-1  | {"level":"info","ts":1712353188.247423,"logger":"http.log","msg":"server running","name":"srv2","protocols":["h1","h2","h3"]}
php-1  | {"level":"info","ts":1712353188.24744,"logger":"http","msg":"enabling HTTP/3 listener","addr":":443"}
php-1  | {"level":"info","ts":1712353188.2475502,"logger":"http.log","msg":"server running","name":"srv0","protocols":["h1","h2","h3"]}
php-1  | {"level":"info","ts":1712353188.2475538,"logger":"http","msg":"enabling automatic TLS certificate management","domains":["localhost"]}
php-1  | {"level":"info","ts":1712353188.247624,"msg":"autosaved config (load with --resume flag)","file":"/config/caddy/autosave.json"}
php-1  | {"level":"info","ts":1712353188.2476285,"msg":"serving initial configuration"}
php-1  | {"level":"info","ts":1712353188.2477212,"logger":"tls.obtain","msg":"acquiring lock","identifier":"localhost"}
php-1  | {"level":"info","ts":1712353188.2477555,"logger":"tls.obtain","msg":"lock acquired","identifier":"localhost"}
php-1  | {"level":"info","ts":1712353188.2477825,"logger":"tls.obtain","msg":"obtaining certificate","identifier":"localhost"}
php-1  | {"level":"info","ts":1712353188.2483377,"logger":"tls.obtain","msg":"certificate obtained successfully","identifier":"localhost"}
php-1  | {"level":"info","ts":1712353188.2483623,"logger":"tls.obtain","msg":"releasing lock","identifier":"localhost"}
php-1  | {"level":"warn","ts":1712353188.248529,"logger":"tls","msg":"stapling OCSP","error":"no OCSP stapling for [localhost]: no OCSP server specified in certificate","identifiers":["localhost"]}
php-1  | SIGSEGV: segmentation violation
php-1 exited with code 0
Dockerfile
ARG DOCKER_HUB_PROXY="registry.hub.docker.com"
FROM $DOCKER_HUB_PROXY/dunglas/frankenphp:latest AS frankenphp_upstream
FROM $DOCKER_HUB_PROXY/dunglas/frankenphp:latest-builder AS frankenphp_builder_upstream
FROM $DOCKER_HUB_PROXY/library/caddy:builder AS caddy_builder_upstream
FROM $DOCKER_HUB_PROXY/composer/composer:2-bin AS composer_upstream

FROM frankenphp_builder_upstream as frankenphp_builder
COPY --from=caddy_builder_upstream /usr/bin/xcaddy /usr/bin/xcaddy

ENV CGO_ENABLED=1 XCADDY_SETCAP=1 CGO_LDFLAGS=-pie XCADDY_GO_BUILD_FLAGS='-buildmode=pie -ldflags="-w -s" -trimpath'
RUN xcaddy build \
    --output /usr/local/bin/frankenphp \
    --with github.com/dunglas/frankenphp=./ \
    --with github.com/dunglas/frankenphp/caddy=./caddy/ \
    --with github.com/dunglas/mercure/caddy \
    --with github.com/dunglas/vulcain/caddy \
    --with github.com/caddyserver/cache-handler

FROM frankenphp_upstream AS frankenphp_base
COPY --from=frankenphp_builder --link /usr/local/bin/frankenphp /usr/local/bin/frankenphp

RUN set -eux; \
    apt-get update; \
    apt-get install -y \
        acl \
        curl \
        file \
        gettext \
        git \
    ; \
    rm -rf /var/lib/apt/lists/*

RUN set -eux; \
    install-php-extensions \
        @composer \
    	amqp \
    	apcu \
    	intl \
	igbinary \
	opcache \
    	openssl \
    	pdo_pgsql \
	redis \
    	zip

RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
COPY --link docker/frankenphp/Caddyfile /etc/caddy/Caddyfile

ARG UID=1000
ARG GID=1000

RUN set -eux; \
    groupadd -g $GID web; \
    useradd -u $UID -d /home/web -m -g web web; \
    mkdir -p /srv/app; chown $UID:$GID /srv/app; \
    mkdir -p /var/run/php; chown $UID:$GID /var/run/php

USER web
WORKDIR /srv/app

HEALTHCHECK --start-period=60s CMD curl -f http://localhost:2019/metrics || exit 1
CMD [ "frankenphp", "run", "--config", "/etc/caddy/Caddyfile" ]

@Renrhaf
Copy link

Renrhaf commented May 8, 2024

Hello, I'm also encountering the same crash after following the https://api-platform.com/docs/core/performance/ tutorial (with fixes from this PR for building the Docker image)

@J-Cake
Copy link

J-Cake commented May 26, 2024

Hey I'm getting the same issue. I've tried to reduce my build as much as possible, but can't really get it down beyond this:

Dockerfile

FROM caddy:2.8-builder-alpine AS builder

RUN apk add build-base

ENV CGO_ENABLED=1 
ENV XCADDY_SETCAP=1 
ENV XCADDY_GO_BUILD_FLAGS="-ldflags '-w -s'"
RUN xcaddy build \
    --output /bin/frankenphp \
    --with github.com/dunglas/frankenphp \
    --with github.com/darkweak/souin/plugins/caddy@c159776e17fdbbf952b8fb4eb9d997918916360e \
    --with github.com/darkweak/souin@c159776e17fdbbf952b8fb4eb9d997918916360e

FROM alpine:latest AS base

COPY --from=fphp /bin/frankenphp /usr/bin/frankenphp

RUN mkdir /download

WORKDIR /download
ADD "https://github.com/mlocati/docker-php-extension-installer/releases/download/2.2.14/install-php-extensions" /usr/bin/install-php-extensions
RUN chmod +x /usr/bin/install-php-extensions

WORKDIR /download
ADD "https://download.nextcloud.com/server/releases/latest.zip" /download/source.zip
RUN unzip source.zip -d /download
RUN mv /download/nextcloud /app
RUN chmod +x /app/occ

ENV XDG_CONFIG_HOME /config
ENV XDG_DATA_HOME /data

VOLUME /config
VOLUME /data

EXPOSE 80
EXPOSE 443
EXPOSE 443/udp
EXPOSE 1920

RUN apk add --no-cache \
        nextcloud-pgsql \
        nextcloud-user_ldap \
        openssl

ENTRYPOINT ["/usr/bin/frankenphp", "run", "--config", "/etc/caddy/Caddyfile"]

Which fails with

--- snip ---
98.03 go: downloading cloud.google.com/go/compute v1.24.0
98.71 2024/05/26 20:36:26 [INFO] exec (timeout=0s): /usr/local/go/bin/go build -o /bin/frankenphp -ldflags -w -s 
103.4 # github.com/dunglas/frankenphp
103.4 In file included from /go/pkg/mod/github.com/dunglas/frankenphp@v1.1.5/cgi.go:3:
103.4 ./frankenphp.h:4:10: fatal error: Zend/zend_types.h: No such file or directory
103.4     4 | #include <Zend/zend_types.h>
103.4       |          ^~~~~~~~~~~~~~~~~~~
103.4 compilation terminated.
105.8 2024/05/26 20:36:33 [INFO] Skipping cleanup as requested; leaving folder intact: /tmp/buildenv_2024-05-26-2034.500546453
105.8 2024/05/26 20:36:33 [FATAL] exit status 1
--- snip ---

@dunglas
Copy link
Owner

dunglas commented May 26, 2024

@J-Cake you should use FrankenPHP "builder" images as base. If you start from Caddy, you have to install PHP by yourself.

https://frankenphp.dev/docs/docker/#how-to-install-more-caddy-modules

@J-Cake
Copy link

J-Cake commented May 26, 2024

@J-Cake you should use FrankenPHP "builder" images as base. If you start from Caddy, you have to install PHP by yourself.

https://frankenphp.dev/docs/docker/#how-to-install-more-caddy-modules

Hi thanks for the quick reply!

I've actually been playing with both. Unfortunately, I get different but similar errors regardless of which image I use.

Anyway, for the sake of this project, I've decided to just use a dedicated cache in a different container, but it would be nice to have them all working together.

Cheers and thanks for your help 🚀

@dunglas
Copy link
Owner

dunglas commented May 27, 2024

The error message you get is just because PHP C file are missing. They are required to compile FrankenPHP.

What is the other error message you get?

@J-Cake
Copy link

J-Cake commented May 27, 2024

Hi apologies for the non-reply again. Here's the error message when building with the frankenphp image:

194.9 go: downloading cloud.google.com/go/compute v1.23.0
196.5 2024/05/27 15:41:09 [INFO] exec (timeout=0s): /usr/local/go/bin/go build -o /bin/frankenphp -ldflags -w -s 
203.5 # caddy
203.5 /usr/local/go/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
203.5 /usr/bin/ld: /tmp/go-link-375663006/000005.o: warning: relocation against `sapi_module' in read-only section `.text'
203.5 /usr/bin/ld: /tmp/go-link-375663006/000005.o: relocation R_X86_64_PC32 against symbol `stderr@@GLIBC_2.2.5' can not be used when making a PDE object; recompile with -fPIE
203.5 /usr/bin/ld: final link failed: bad value
203.5 collect2: error: ld returned 1 exit status
203.5 
203.6 2024/05/27 15:41:16 [INFO] Cleaning up temporary folder: /tmp/buildenv_2024-05-27-1537.638876492
203.6 2024/05/27 15:41:16 [FATAL] exit status 1
Dockerfile

```Dockerfile FROM dunglas/frankenphp:latest-builder AS builder

Copy xcaddy in the builder image

COPY --from=caddy:builder /usr/bin/xcaddy /usr/bin/xcaddy

CGO must be enabled to build FrankenPHP

ENV CGO_ENABLED=1 XCADDY_SETCAP=1 XCADDY_GO_BUILD_FLAGS="-ldflags '-w -s'"

ENV CGO_ENABLED=1
ENV XCADDY_SETCAP=1
ENV XCADDY_GO_BUILD_FLAGS="-ldflags '-w -s'"
RUN xcaddy build
--output /bin/frankenphp
--with github.com/caddyserver/cache-handler
--with github.com/dunglas/frankenphp

</p>
</details> 

@g-ra
Copy link

g-ra commented Jul 31, 2024

i have same issue #944 with apiplatform

@sneycampos
Copy link
Contributor

i have same issue #944 with apiplatform

Could you please stop to reference your issue in all frankenphp issues?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants