Skip to content

Set FrankenPHP and PHP version when building with xcaddy #1364

@kichetof

Description

@kichetof

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!!

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions