frankenphp icon indicating copy to clipboard operation
frankenphp copied to clipboard

Same problem as in your CI when building a static binary

Open Suven opened this issue 6 months ago • 4 comments

What happened?

Hey,

I wanted to build a static binary including all default extensions + mongodb, but am receiving the same error you are also receiving in your ci.

Error

0.454 + CURRENT_REF=HEAD
0.454 + export CURRENT_REF
0.454 + echo dev
0.455 + grep -F -q .
0.456 + git checkout dev
0.464 error: pathspec 'dev' did not match any file(s) known to git
------
static-builder-musl.Dockerfile:102
--------------------
 101 |
 102 | >>> RUN --mount=type=secret,id=github-token GITHUB_TOKEN=$(cat /run/secrets/github-token) ./build-static.sh && \
 103 | >>> 	rm -Rf dist/static-php-cli/source/*
 104 |
--------------------
ERROR: failed to solve: process "/bin/ash -eo pipefail -c GITHUB_TOKEN=$(cat /run/secrets/github-token) ./build-static.sh && \trm -Rf dist/static-php-cli/source/*" did not complete successfully: exit code: 1

What I tried

  • Running with the checked out main-branch
  • Running with a checked out tag (1.7 as well as 1.6.2) as there the ci ran green for you. Results in the same error

My command

docker buildx bake --set "*.platform=linux/amd64" --set static-builder-musl.args.PHP_EXTENSIONS=ctype,iconv,pcntl,posix,filter,mbstring,openssl,readline,sodium,zlib,curl,ffi,fileinfo,tokenizer,xml,dom,simplexml,xmlreader,xmlwriter,session,pdo,sqlite3,mongodb static-builder-musl

On another note

You don't have, by any chance, binaries with more extensions laying around anywhere? ^^' The mongo-support is kind of critical for an app that I already deployed to prod by oversight. The prod-server doesn't have support for building from source or docker (it's managed).

Build Type

Custom (tell us more in the description)

Worker Mode

Yes

Operating System

GNU/Linux

CPU Architecture

x86_64

PHP configuration

Not relevant

Relevant log output


Suven avatar Jun 18 '25 07:06 Suven

0.454 + CURRENT_REF=HEAD
0.454 + export CURRENT_REF
0.454 + echo dev
0.455 + grep -F -q .
0.456 + git checkout dev

Looks like

if [ -z "${FRANKENPHP_VERSION}" ]; then
	FRANKENPHP_VERSION="$(git rev-parse --verify HEAD)"
	export FRANKENPHP_VERSION
elif [ -d ".git/" ]; then
	CURRENT_REF="$(git rev-parse --abbrev-ref HEAD)"
	export CURRENT_REF

	if echo "${FRANKENPHP_VERSION}" | grep -F -q "."; then
		# Tag

		# Trim "v" prefix if any
		FRANKENPHP_VERSION=${FRANKENPHP_VERSION#v}
		export FRANKENPHP_VERSION

		git checkout "v${FRANKENPHP_VERSION}"
	else
		git checkout "${FRANKENPHP_VERSION}"
	fi
fi

It's entering the second block where .git exists and FRANKENPHP_VERSION was passed.

henderkes avatar Jun 19 '25 13:06 henderkes

Please make sure you clear your FRANKENPHP_VERSION variable and try again.

henderkes avatar Jun 19 '25 13:06 henderkes

That happens on a clean linux without me setting any env. I guess you previously had a dev branch and deleted it, as you are also having the same issue?

dev is set as var that is being passed here:

https://github.com/php/frankenphp/blob/main/docker-bake.hcl

So I guess I could fix it for my usage by passing a specific version to bake

Edit: weird. I was super sure I saw the exact same output in your pipelines on the master branch. But I can not find it anymore

Suven avatar Jun 20 '25 10:06 Suven

https://github.com/php/frankenphp/actions/runs/15774481399/job/44465728535

The last runs are not failing.

henderkes avatar Jun 20 '25 11:06 henderkes

I can not find it anymore. Anyway, with setting a variable it works

VERSION=1.7.0 docker buildx bake --set "*.platform=linux/amd64" --set static-builder-musl.args.PHP_EXTENSIONS=ctype,iconv,pcntl,posix,filter,mbstring,openssl,readline,sodium,zlib,curl,ffi,fileinfo,tokenizer,xml,dom,simplexml,xmlreader,xmlwriter,session,pdo,sqlite3,mongodb static-builder-musl

Maybe this should be added to the docs: https://frankenphp.dev/docs/static/

Or you could change the default in https://github.com/php/frankenphp/blob/main/docker-bake.hcl to something existing like main

Suven avatar Jun 23 '25 07:06 Suven