frankenphp icon indicating copy to clipboard operation
frankenphp copied to clipboard

Tag nobrotli doesn't properly work

Open Allespro opened this issue 10 months ago • 5 comments

What happened?

Hello, I use Docker image ubuntu:20.04 to compile frankenphp like here https://frankenphp.dev/docs/compile/#compile-the-go-app here is my command with nobrotli and it works but not at all.

tar -xf main.tar.gz && \
    cd frankenphp-main/caddy/frankenphp && \
    CGO_CFLAGS=$(php-config --includes) CGO_LDFLAGS="$(php-config --ldflags) $(php-config --libs)" go build -o frankenphp -tags=nobrotli,nowatcher

here is output when nobrotli disabled

#19 276.1 # github.com/google/brotli/go/cbrotli
#19 276.1 /root/go/pkg/mod/github.com/google/brotli/go/[email protected]/writer.go:13:10: fatal error: brotli/encode.h: No such file or directory
#19 276.1    13 | #include <brotli/encode.h>
#19 276.1       |          ^~~~~~~~~~~~~~~~~
#19 276.1 compilation terminated.
#19 ERROR: process "/bin/sh -c tar -xf main.tar.gz &&     cd frankenphp-main/caddy/frankenphp &&     CGO_CFLAGS=$(php-config --includes) CGO_LDFLAGS=\"$(php-config --ldflags) $(php-config --libs)\" go build -o frankenphp -tags=nowatcher" did not complete successfully: exit code: 1
------
 > [builder 15/15] RUN tar -xf main.tar.gz &&     cd frankenphp-main/caddy/frankenphp &&     CGO_CFLAGS=$(php-config --includes) CGO_LDFLAGS="$(php-config --ldflags) $(php-config --libs)" go build -o frankenphp -tags=nowatcher:
236.8 go: downloading github.com/bits-and-blooms/bitset v1.20.0
276.1 # github.com/google/brotli/go/cbrotli
276.1 /root/go/pkg/mod/github.com/google/brotli/go/[email protected]/writer.go:13:10: fatal error: brotli/encode.h: No such file or directory
276.1    13 | #include <brotli/encode.h>
276.1       |          ^~~~~~~~~~~~~~~~~
276.1 compilation terminated.

and here is when nobrotli enabled

#19 265.9 # github.com/google/brotli/go/cbrotli
#19 265.9 /root/go/pkg/mod/github.com/google/brotli/go/[email protected]/reader.go:13:10: fatal error: brotli/decode.h: No such file or directory
#19 265.9    13 | #include <brotli/decode.h>
#19 265.9       |          ^~~~~~~~~~~~~~~~~
#19 265.9 compilation terminated.
#19 ERROR: process "/bin/sh -c tar -xf main.tar.gz &&     cd frankenphp-main/caddy/frankenphp &&     CGO_CFLAGS=$(php-config --includes) CGO_LDFLAGS=\"$(php-config --ldflags) $(php-config --libs)\" go build -o frankenphp -tags=nobrotli,nowatcher" did not complete successfully: exit code: 1
------
 > [builder 15/15] RUN tar -xf main.tar.gz &&     cd frankenphp-main/caddy/frankenphp &&     CGO_CFLAGS=$(php-config --includes) CGO_LDFLAGS="$(php-config --ldflags) $(php-config --libs)" go build -o frankenphp -tags=nobrotli,nowatcher:
215.9 go: downloading github.com/bits-and-blooms/bitset v1.20.0
265.9 # github.com/google/brotli/go/cbrotli
265.9 /root/go/pkg/mod/github.com/google/brotli/go/[email protected]/reader.go:13:10: fatal error: brotli/decode.h: No such file or directory
265.9    13 | #include <brotli/decode.h>
265.9       |          ^~~~~~~~~~~~~~~~~
265.9 compilation terminated.

difference is in encode.h | decode.h

look like brotli still used in project but I really don't need it

Build Type

Custom (tell us more in the description)

Worker Mode

No

Operating System

GNU/Linux

CPU Architecture

x86_64

PHP configuration

-

Relevant log output


Allespro avatar Feb 16 '25 01:02 Allespro

after command apt install libbrotli-dev there is no error. but that means brotli is used in build

Allespro avatar Feb 16 '25 02:02 Allespro

It's not required for the frankenphp, but required for compilation by default: https://github.com/dunglas/frankenphp/blob/4c92633396f7629503cbfc69dee418e28018623b/caddy/frankenphp/main.go#L8

Note that during compilation it should get optimized out since nothing is using it.

withinboredom avatar Feb 16 '25 10:02 withinboredom

Using xcaddy to build FrankenPHP should allow to build without the brotli library.

dunglas avatar Feb 16 '25 12:02 dunglas

Then it makes no sense to use the nobrotli flag if build via go build and not via xcaddy build?

Allespro avatar Feb 16 '25 17:02 Allespro

Yes indeed. We should improve the docs.

dunglas avatar Feb 16 '25 18:02 dunglas