Skip to content

[Missing package] Unable to build static binary #1896

@kranack

Description

@kranack

What happened?

During the static build, an error about the package "patchelf" occured during the spc doctor command.

I fixed it by adding the following command in my Dockerfile (found here)

RUN curl -fsSL -o patchelf.tgz https://github.com/NixOS/patchelf/releases/download/0.18.0/patchelf-0.18.0-x86_64.tar.gz && \
    mkdir -p /patchelf && \
    tar -xzf patchelf.tgz -C /patchelf --strip-components=1 && \
    cp /patchelf/bin/patchelf /usr/bin/

Build Type

Official static build

Worker Mode

Yes

Operating System

GNU/Linux

CPU Architecture

x86_64

PHP configuration

Docker image: dunglas/frankenphp:static-builder-gnu
Static parameters:
PHP_EXTENSIONS=amqp,brotli,bz2,ctype,curl,dom,fileinfo,filter,iconv,intl,ldap,libxml,lz4,pdo_sqlite,session,sodium,sqlite3,ssh2,xml,xmlreader,xmlwriter,xz,zip,zlib,zstd

Relevant log output

> docker build -f ./static-build.Dockerfile .
[+] Building 4.1s (9/9) FINISHED                                                                                                                                  docker:default
 => [internal] load build definition from static-build.Dockerfile                                                                                                           0.0s
 => => transferring dockerfile: 766B                                                                                                                                        0.0s
 => WARN: FromPlatformFlagConstDisallowed: FROM --platform flag should not use constant value "linux/amd64" (line 1)                                                        0.0s
 => [internal] load metadata for docker.io/dunglas/frankenphp:static-builder-gnu                                                                                            0.2s
 => [internal] load .dockerignore                                                                                                                                           0.0s
 => => transferring context: 637B                                                                                                                                           0.0s
 => [1/5] FROM docker.io/dunglas/frankenphp:static-builder-gnu@sha256:2de0bd15fdbcd8fdd9e5c1036a8753c5553c8895c202e4e500e63732723ca774                                      0.0s
 => [internal] load build context                                                                                                                                           0.0s
 => => transferring context: 11.06kB                                                                                                                                        0.0s
 => CACHED [2/5] WORKDIR /go/src/app/dist/app                                                                                                                               0.0s
 => [3/5] COPY . .                                                                                                                                                          0.1s
 => [4/5] WORKDIR /go/src/app/                                                                                                                                              0.0s
 => ERROR [5/5] RUN EMBED=dist/app/     PHP_EXTENSIONS=amqp,brotli,bz2,ctype,curl,dom,fileinfo,filter,iconv,intl,ldap,libxml,lz4,pdo_sqlite,session,sodium,sqlite3,ssh2,xm  3.6s
------                                                                                                                                                                           
 > [5/5] RUN EMBED=dist/app/     PHP_EXTENSIONS=amqp,brotli,bz2,ctype,curl,dom,fileinfo,filter,iconv,intl,ldap,libxml,lz4,pdo_sqlite,session,sodium,sqlite3,ssh2,xml,xmlreader,xmlwriter,xz,zip,zlib,zstd     ./build-static.sh:                                                                                                                                  
0.137 + type git                                                                                                                                                                 
0.137 ++ uname -m                                                                                                                                                                
0.138 + arch=x86_64                                                                                                                                                              
0.138 ++ uname -s
0.139 ++ tr '[:upper:]' '[:lower:]'
0.139 + os=linux
0.139 + '[' -z binary ']'
0.139 + '[' -z glibc ']'
0.139 + '[' -z '--with-config-file-path=/etc/frankenphp --with-config-file-scan-dir=/etc/frankenphp/php.d' ']'
0.139 + '[' glibc = musl ']'
0.139 + '[' -z '' ']'
0.139 + SPC_OPT_DOWNLOAD_ARGS='--ignore-cache-sources=php-src --retry 5'
0.139 + '[' glibc = musl ']'
0.139 + '[' -n '' ']'
0.139 + '[' -z '' ']'
0.140 ++ get_latest_php_version 8.4
0.140 ++ input=8.4
0.140 +++ curl -s 'https://www.php.net/releases/index.php?json&version=8.4'
0.435 ++ json='{"announcement":true,"tags":[""],"date":"28 Aug 2025","source":[{"filename":"php-8.4.12.tar.gz","name":"PHP 8.4.12 (tar.gz)","sha256":"4963b0d3a6ca8a391317d1b80309c2cfdebf4318b131ff8e7d19e3ab79da9104","date":"28 Aug 2025"},{"filename":"php-8.4.12.tar.bz2","name":"PHP 8.4.12 (tar.bz2)","sha256":"2ebd5382eb090d603087da649ed21de64b079616bc9a02abbc532b89b17e3468","date":"28 Aug 2025"},{"filename":"php-8.4.12.tar.xz","name":"PHP 8.4.12 (tar.xz)","sha256":"c1b7978cbb5054eed6c749bde4444afc16a3f2268101fb70a7d5d9b1083b12ad","date":"28 Aug 2025"}],"supported_versions":["8.1","8.2","8.3","8.4"],"version":"8.4.12"}'
0.436 +++ echo '{"announcement":true,"tags":[""],"date":"28 Aug 2025","source":[{"filename":"php-8.4.12.tar.gz","name":"PHP 8.4.12 (tar.gz)","sha256":"4963b0d3a6ca8a391317d1b80309c2cfdebf4318b131ff8e7d19e3ab79da9104","date":"28 Aug 2025"},{"filename":"php-8.4.12.tar.bz2","name":"PHP 8.4.12 (tar.bz2)","sha256":"2ebd5382eb090d603087da649ed21de64b079616bc9a02abbc532b89b17e3468","date":"28 Aug 2025"},{"filename":"php-8.4.12.tar.xz","name":"PHP 8.4.12 (tar.xz)","sha256":"c1b7978cbb5054eed6c749bde4444afc16a3f2268101fb70a7d5d9b1083b12ad","date":"28 Aug 2025"}],"supported_versions":["8.1","8.2","8.3","8.4"],"version":"8.4.12"}'
0.436 +++ jq -r .version
0.482 ++ latest=8.4.12
0.482 ++ [[ 8.4.12 == \8\.\4* ]]
0.482 ++ echo 8.4.12
0.482 + PHP_VERSION=8.4.12
0.482 + export PHP_VERSION
0.482 + defaultExtensions=amqp,apcu,ast,bcmath,brotli,bz2,calendar,ctype,curl,dba,dom,exif,fileinfo,filter,ftp,gd,gmp,gettext,iconv,igbinary,imagick,intl,ldap,lz4,mbregex,mbstring,memcache,memcached,mysqli,mysqlnd,opcache,openssl,password-argon2,parallel,pcntl,pdo,pdo_mysql,pdo_pgsql,pdo_sqlite,pdo_sqlsrv,pgsql,phar,posix,protobuf,readline,redis,session,shmop,simplexml,soap,sockets,sodium,sqlite3,ssh2,sysvmsg,sysvsem,sysvshm,tidy,tokenizer,xlswriter,xml,xmlreader,xmlwriter,xz,zip,zlib,yaml,zstd
0.482 + defaultExtensionLibs=libavif,nghttp2,nghttp3,ngtcp2
0.482 + md5binary=md5sum
0.482 + '[' linux = darwin ']'
0.482 + '[' linux = linux ']'
0.482 + type cmake
0.482 + '[' linux = linux ']'
0.482 + [[ x86_64 =~ aarch ]]
0.482 + [[ x86_64 =~ arm ]]
0.482 + fpic=-fpic
0.482 + fpie=-fpie
0.482 + '[' -z v1.9.1 ']'
0.482 + '[' -d .git/ ']'
0.482 + bin=frankenphp-linux-x86_64
0.482 + '[' -n '' ']'
0.482 + mkdir -p dist/
0.483 + cd dist/
0.483 + type brew
0.484 + '[' binary = binary ']'
0.484 + mkdir -p static-php-cli/
0.484 + cd static-php-cli/
0.484 + [[ x86_64 =~ arm ]]
0.484 + dl_arch=x86_64
0.484 + curl -o spc -fsSL https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-linux-x86_64
2.193 + chmod +x spc
2.195 + spcCommand=./spc
2.195 + '[' -z amqp,brotli,bz2,ctype,curl,dom,fileinfo,filter,iconv,intl,ldap,libxml,lz4,pdo_sqlite,session,sodium,sqlite3,ssh2,xml,xmlreader,xmlwriter,xz,zip,zlib,zstd ']'
2.195 + '[' -z '' ']'
2.195 + PHP_EXTENSION_LIBS=libavif,nghttp2,nghttp3,ngtcp2
2.195 + echo libavif,nghttp2,nghttp3,ngtcp2
2.195 + grep -q '\bbrotli\b'
2.196 + PHP_EXTENSION_LIBS=libavif,nghttp2,nghttp3,ngtcp2,brotli
2.196 + '[' -n '' ']'
2.196 + cache_key=8.4.12-amqp,brotli,bz2,ctype,curl,dom,fileinfo,filter,iconv,intl,ldap,libxml,lz4,pdo_sqlite,session,sodium,sqlite3,ssh2,xml,xmlreader,xmlwriter,xz,zip,zlib,zstd-libavif,nghttp2,nghttp3,ngtcp2,brotli
2.196 + '[' -f ../cache_key ']'
2.196 ++ cat ../cache_key
2.197 + '[' 8.4.12-amqp,apcu,ast,bcmath,brotli,bz2,calendar,ctype,curl,dba,dom,exif,fileinfo,filter,ftp,gd,gmp,gettext,iconv,igbinary,imagick,intl,ldap,lz4,mbregex,mbstring,memcache,memcached,mysqli,mysqlnd,opcache,openssl,password-argon2,parallel,pcntl,pdo,pdo_mysql,pdo_pgsql,pdo_sqlite,pdo_sqlsrv,pgsql,phar,posix,protobuf,readline,redis,session,shmop,simplexml,soap,sockets,sodium,sqlite3,ssh2,sysvmsg,sysvsem,sysvshm,tidy,tokenizer,xlswriter,xml,xmlreader,xmlwriter,xz,zip,zlib,yaml,zstd-libavif,nghttp2,nghttp3,ngtcp2,brotli = 8.4.12-amqp,brotli,bz2,ctype,curl,dom,fileinfo,filter,iconv,intl,ldap,libxml,lz4,pdo_sqlite,session,sodium,sqlite3,ssh2,xml,xmlreader,xmlwriter,xz,zip,zlib,zstd-libavif,nghttp2,nghttp3,ngtcp2,brotli ']'
2.197 + ./spc doctor --auto-fix
2.261      _        _   _                 _
2.261  ___| |_ __ _| |_(_) ___      _ __ | |__  _ __
2.261 / __| __/ _` | __| |/ __|____| '_ \| '_ \| '_ \
2.261 \__ \ || (_| | |_| | (_|_____| |_) | | | | |_) |
2.261 |___/\__\__,_|\__|_|\___|    | .__/|_| |_| .__/   v2.7.4
2.261                              |_|         |_|
2.272 Checking if current OS are supported ... Linux x86_64 centos, supported
2.272 Checking if necessary tools are installed ... patchelf not installed on your system
2.272 Automatically fixing install-linux-tools ...
2.275 [11:49:49] [I] [EXEC] yum install -y patchelf
2.397 Loaded plugins: fastestmirror, ovl
2.506 Loading mirror speeds from cached hostfile
3.536 No package patchelf available.
3.570 Error: Nothing to do
3.579 Fix failed: Command exited with non-zero code: 1
3.579 Failed to apply fix!
------

 1 warning found (use docker --debug to expand):
 - FromPlatformFlagConstDisallowed: FROM --platform flag should not use constant value "linux/amd64" (line 1)
static-build.Dockerfile:15
--------------------
  14 |     WORKDIR /go/src/app/
  15 | >>> RUN EMBED=dist/app/ \
  16 | >>>     PHP_EXTENSIONS=amqp,brotli,bz2,ctype,curl,dom,fileinfo,filter,iconv,intl,ldap,libxml,lz4,pdo_sqlite,session,sodium,sqlite3,ssh2,xml,xmlreader,xmlwriter,xz,zip,zlib,zstd \
  17 | >>>     ./build-static.sh
  18 |     
--------------------
ERROR: failed to build: failed to solve: process "/bin/bash -o pipefail -c EMBED=dist/app/     PHP_EXTENSIONS=amqp,brotli,bz2,ctype,curl,dom,fileinfo,filter,iconv,intl,ldap,libxml,lz4,pdo_sqlite,session,sodium,sqlite3,ssh2,xml,xmlreader,xmlwriter,xz,zip,zlib,zstd     ./build-static.sh" did not complete successfully: exit code: 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions