frankenphp icon indicating copy to clipboard operation
frankenphp copied to clipboard

Set FrankenPHP and PHP version when building with xcaddy

Open kichetof opened this issue 11 months ago • 2 comments

Describe you feature request

Hi,

I build a docker image according to How to Install More Caddy Modules. Everything works well!

I can show when displaying FrankenPHP version echo phpversion('frankenphp');, it display "dev" instead of "vX.X.X".

I tried with both env (VERSION or FRANKENPHP_VERSION), but nothing works as expected:

ARG PHP_VERSION=8.3
ARG FRANKENPHP_VERSION=1

FROM dunglas/frankenphp:${FRANKENPHP_VERSION}-builder-php${PHP_VERSION} AS builder
COPY --from=caddy:builder /usr/bin/xcaddy /usr/bin/xcaddy
RUN CGO_ENABLED=1 \
    XCADDY_SETCAP=1 \
    XCADDY_GO_BUILD_FLAGS="-ldflags='-w -s' -tags=nobadger,nomysql,nopgx" \
    #VERSION=$(echo $CGO_CFLAGS | grep -oP '(?<=-DFRANKENPHP_VERSION=)[^ ]+') \
    #FRANKENPHP_VERSION=$(echo $CGO_CFLAGS | grep -oP '(?<=-DFRANKENPHP_VERSION=)[^ ]+') \
    CGO_CFLAGS=$(php-config --includes) \
    CGO_LDFLAGS="$(php-config --ldflags) $(php-config --libs)" \
    xcaddy build \
        --output /usr/local/bin/frankenphp \
        --with github.com/dunglas/frankenphp=./ \
        --with github.com/dunglas/frankenphp/caddy=./caddy/ \
        --with github.com/dunglas/caddy-cbrotli

FROM dunglas/frankenphp:${FRANKENPHP_VERSION}-php${PHP_VERSION} AS base

COPY --from=builder /usr/local/bin/frankenphp /usr/local/bin/frankenphp-test

And my versions output:

root@6ab7bfe37678:/app# frankenphp -v
FrankenPHP v1.4.2 PHP 8.3.16 Caddy v2.9.1 h1:OEYiZ7DbCzAWVb6TNEkjRcSCRGHVoZsJinoDR/n9oaY=
root@6ab7bfe37678:/app# frankenphp-test -v
v2.9.1 h1:OEYiZ7DbCzAWVb6TNEkjRcSCRGHVoZsJinoDR/n9oaY=

Should it be possible to tag the builder version according to the FrankenPHP tagged version in the builder image ?

Thanks a lot!!

kichetof avatar Feb 07 '25 13:02 kichetof

could be related to https://github.com/dunglas/frankenphp/pull/1248#issuecomment-2619785807

kichetof avatar Feb 13 '25 09:02 kichetof

Indeed! I believe it is exactly related. Hoping to get to that this weekend actually.

withinboredom avatar Feb 15 '25 08:02 withinboredom