dunglas / frankenphp

🧟 The modern PHP app server
https://frankenphp.dev
MIT License
6.85k stars 235 forks source link

./frankenphp.h:4:10: fatal error: Zend/zend_types.h: No such file or directory #946

Closed g-ra closed 3 months ago

g-ra commented 3 months ago

What happened?

i cant install cache-handler for xcaddy

FROM debian:bookworm AS builder

# Install necessary packages
RUN apt-get update && apt-get install -y --no-install-recommends \
    git \
    build-essential \
    wget \
    ca-certificates \
    libxml2-dev \
    libssl-dev \
    libcurl4-openssl-dev \
    pkg-config \
    zlib1g-dev \
    libpng-dev \
    libjpeg-dev \
    libfreetype6-dev \
    libonig-dev \
    libzip-dev \
    libicu-dev \
    php-dev \
    php-pear \
    && rm -rf /var/lib/apt/lists/*

# Install Go
ENV GO_VERSION=1.21.1
RUN wget https://golang.org/dl/go${GO_VERSION}.linux-amd64.tar.gz && \
    tar -C /usr/local -xzf go${GO_VERSION}.linux-amd64.tar.gz && \
    rm go${GO_VERSION}.linux-amd64.tar.gz

# Set Go environment variables
ENV GOROOT=/usr/local/go
ENV GOPATH=/go
ENV PATH=$GOROOT/bin:$GOPATH/bin:$PATH

# Install xcaddy
RUN go install github.com/caddyserver/xcaddy/cmd/xcaddy@latest

# Clone FrankenPHP repository
RUN git clone https://github.com/dunglas/frankenphp.git /src/frankenphp

WORKDIR /src/frankenphp

# Set environment variables for PIE
ENV CGO_ENABLED=1
ENV XCADDY_SETCAP=1
ENV XCADDY_GO_BUILD_FLAGS="-ldflags \"-w -s -extldflags '-Wl,-z,stack-size=0x80000'\""
ENV CGO_CFLAGS="-fPIC" \
    CGO_LDFLAGS="-pie" \
    GOFLAGS="-buildmode=pie"
# Build FrankenPHP with xcaddy
RUN xcaddy build \
    --output /usr/local/bin/frankenphp \
    --with github.com/dunglas/frankenphp \
    --with github.com/dunglas/frankenphp/caddy \
    --with github.com/dunglas/mercure/caddy \
    --with github.com/dunglas/vulcain/caddy \
    --with github.com/darkweak/souin \
    --with github.com/caddyserver/cache-handler

FROM dunglas/frankenphp:latest AS frankenphp_upstream
COPY --from=builder --link /usr/local/bin/frankenphp /usr/local/bin/frankenphp

Build Type

Docker (Debian Bookworm)

Worker Mode

Yes

Operating System

GNU/Linux

CPU Architecture

x86_64

PHP configuration

from bookwarm

Relevant log output


[+] Building 96.1s (15/36)                                                                                                                                                                 docker:default
 => [php internal] load build definition from Dockerfile                                                                                                                                             0.0s
 => => transferring dockerfile: 7.25kB                                                                                                                                                               0.0s 
 => [php] resolve image config for docker-image://docker.io/docker/dockerfile:1.4                                                                                                                    1.2s
 => CACHED [php] docker-image://docker.io/docker/dockerfile:1.4@sha256:9ba7531bd80fb0a858632727cf7a112fbfd19b17e94c4e84ced81e24ef1a0dbc                                                              0.0s
 => => resolve docker.io/docker/dockerfile:1.4@sha256:9ba7531bd80fb0a858632727cf7a112fbfd19b17e94c4e84ced81e24ef1a0dbc                                                                               0.0s 
 => [php internal] load .dockerignore                                                                                                                                                                0.0s 
 => => transferring context: 561B                                                                                                                                                                    0.0s 
 => [php internal] load metadata for docker.io/library/debian:bookworm                                                                                                                               1.0s 
 => [php internal] load metadata for docker.io/dunglas/frankenphp:latest                                                                                                                             1.1s 
 => [php frankenphp_upstream 1/2] FROM docker.io/dunglas/frankenphp:latest@sha256:6f57cd6568924291cceeaff59e0e184d2953941b11ad77b0f54a18011fddcdd5                                                   0.0s
 => => resolve docker.io/dunglas/frankenphp:latest@sha256:6f57cd6568924291cceeaff59e0e184d2953941b11ad77b0f54a18011fddcdd5                                                                           0.0s 
 => [php builder 1/7] FROM docker.io/library/debian:bookworm@sha256:45f2e735295654f13e3be10da2a6892c708f71a71be845818f6058982761a6d3                                                                 0.0s
 => => resolve docker.io/library/debian:bookworm@sha256:45f2e735295654f13e3be10da2a6892c708f71a71be845818f6058982761a6d3                                                                             0.0s 
 => [php internal] load build context                                                                                                                                                                0.1s 
 => => transferring context: 102.10kB                                                                                                                                                                0.1s 
 => CACHED [php builder 2/7] RUN apt-get update && apt-get install -y --no-install-recommends     git     build-essential     wget     ca-certificates     libxml2-dev     libssl-dev     libcurl4-  0.0s 
 => CACHED [php builder 3/7] RUN wget https://golang.org/dl/go1.21.1.linux-amd64.tar.gz &&     tar -C /usr/local -xzf go1.21.1.linux-amd64.tar.gz &&     rm go1.21.1.linux-amd64.tar.gz              0.0s 
 => CACHED [php builder 4/7] RUN go install github.com/caddyserver/xcaddy/cmd/xcaddy@latest                                                                                                          0.0s 
 => CACHED [php builder 5/7] RUN git clone https://github.com/dunglas/frankenphp.git /src/frankenphp                                                                                                 0.0s 
 => CACHED [php builder 6/7] WORKDIR /src/frankenphp                                                                                                                                                 0.0s 
 => ERROR [php builder 7/7] RUN xcaddy build     --output /usr/local/bin/frankenphp     --with github.com/dunglas/frankenphp     --with github.com/dunglas/frankenphp/caddy     --with github.com/  93.7s 
------
 > [php builder 7/7] RUN xcaddy build     --output /usr/local/bin/frankenphp     --with github.com/dunglas/frankenphp     --with github.com/dunglas/frankenphp/caddy     --with github.com/dunglas/mercure/caddy     --with github.com/dunglas/vulcain/caddy     --with github.com/darkweak/souin     --with github.com/caddyserver/cache-handler:
0.249 2024/07/31 19:35:09 [INFO] absolute output file path: /usr/local/bin/frankenphp
0.249 2024/07/31 19:35:09 [INFO] Temporary folder: /tmp/buildenv_2024-07-31-1935.3635216338
0.249 2024/07/31 19:35:09 [INFO] Writing main module: /tmp/buildenv_2024-07-31-1935.3635216338/main.go
0.249 package main
0.249
0.249 import (
0.249   caddycmd "github.com/caddyserver/caddy/v2/cmd"
0.249
0.249   // plug in Caddy modules here
0.249   _ "github.com/caddyserver/caddy/v2/modules/standard"
0.249   _ "github.com/dunglas/frankenphp"
0.249   _ "github.com/dunglas/frankenphp/caddy"
0.249   _ "github.com/dunglas/mercure/caddy"
0.249   _ "github.com/dunglas/vulcain/caddy"
0.249   _ "github.com/darkweak/souin"
0.249   _ "github.com/caddyserver/cache-handler"
0.249 )
0.249
0.249 func main() {
0.249   caddycmd.Main()
0.249 }
0.249 2024/07/31 19:35:09 [INFO] Initializing Go module
0.249 2024/07/31 19:35:09 [INFO] exec (timeout=0s): /usr/local/go/bin/go mod init caddy
0.251 go: creating new go.mod: module caddy
0.252 go: to add module requirements and sums:
0.252   go mod tidy
0.252 2024/07/31 19:35:09 [INFO] Pinning versions
0.252 2024/07/31 19:35:09 [INFO] exec (timeout=0s): /usr/local/go/bin/go get -d -v -ldflags -w -s -e20240606120523-5a60cdf6a761
41.30 go: added github.com/jackc/pgx/v5 v5.6.0
41.30 go: added github.com/jackc/puddle/v2 v2.2.1
41.30 go: added github.com/kevburnsjr/skipfilter v0.0.1
41.30 go: upgraded github.com/klauspost/compress v1.17.8 => v1.17.9
41.30 go: upgraded github.com/klauspost/cpuid/v2 v2.2.7 => v2.2.8
41.30 go: added github.com/magiconair/properties v1.8.7
41.30 go: upgraded github.com/miekg/dns v1.1.59 => v1.1.61
41.30 go: added github.com/mitchellh/mapstructure v1.5.0
41.30 go: added github.com/mschoch/smat v0.2.0
41.30 go: added github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822

69.23 go: downloading github.com/aws/aws-sdk-go-v2 v1.30.1
69.26 go: downloading gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7
69.26 go: downloading cloud.google.com/go v0.115.0
69.42 go: downloading github.com/rogpeppe/go-internal v1.12.0
69.42 go: downloading github.com/kr/text v0.2.0
69.62 go: downloading github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.13
69.67 go: downloading github.com/aws/smithy-go v1.20.3
69.75 go: downloading github.com/aws/aws-sdk-go-v2/credentials v1.17.21
70.06 go: downloading github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.8
70.06 go: downloading github.com/aws/aws-sdk-go-v2/internal/ini v1.8.0
70.06 go: downloading github.com/aws/aws-sdk-go-v2/service/sso v1.21.1
70.06 go: downloading github.com/aws/aws-sdk-go-v2/service/ssooidc v1.25.1
70.06 go: downloading github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.13
70.06 go: downloading github.com/aws/aws-sdk-go-v2/service/sts v1.29.1
70.06 go: downloading cloud.google.com/go/iam v1.1.8
70.06 go: downloading cloud.google.com/go/longrunning v0.5.7
70.28 go: downloading google.golang.org/genproto v0.0.0-20240624140628-dc46fd24d27d
70.33 go: downloading github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.2
70.33 go: downloading github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.14
73.55 go: downloading cloud.google.com/go/auth v0.6.1
73.55 go: downloading golang.org/x/oauth2 v0.21.0
73.55 go: downloading github.com/googleapis/enterprise-certificate-proxy v0.3.2
73.55 go: downloading cloud.google.com/go/auth/oauth2adapt v0.2.2
73.55 go: downloading cloud.google.com/go/compute/metadata v0.3.0
73.55 go: downloading github.com/google/s2a-go v0.1.7
73.55 go: downloading go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0
73.95 go: downloading cloud.google.com/go/compute v1.24.0
74.47 2024/07/31 19:36:24 [INFO] exec (timeout=0s): /usr/local/go/bin/go build -o /usr/local/bin/frankenphp -ldflags -w -s -extldflags '-Wl,-z,stack-size=0x80000'
88.41 # github.com/dunglas/frankenphp
88.41 In file included from /go/pkg/mod/github.com/dunglas/frankenphp@v1.2.2/cgi.go:3:
88.41 ./frankenphp.h:4:10: fatal error: Zend/zend_types.h: No such file or directory
88.41     4 | #include <Zend/zend_types.h>
88.41       |          ^~~~~~~~~~~~~~~~~~~
88.41 compilation terminated.
93.34 2024/07/31 19:36:43 [INFO] Cleaning up temporary folder: /tmp/buildenv_2024-07-31-1935.3635216338
93.34 2024/07/31 19:36:43 [FATAL] exit status 1
------
failed to solve: process "/bin/sh -c xcaddy build     --output /usr/local/bin/frankenphp     --with github.com/dunglas/frankenphp     --with github.com/dunglas/frankenphp/caddy     --with github.com/dunglas/mercure/caddy     --with github.com/dunglas/vulcain/caddy     --with github.com/darkweak/souin     --with github.com/caddyserver/cache-handler" did not complete successfully: exit code: 1
withinboredom commented 3 months ago

This isn't a bug. You have to install php sources to compile frankenphp. FWIW, it's much simpler to do this by basing off of the php images and/or frankenphp builder images.

g-ra commented 3 months ago

@withinboredom sry, can you share example ?

g-ra commented 3 months ago
FROM php:8.3-fpm-bullseye AS builder

# Install necessary packages
RUN apt-get update && apt-get install -y --no-install-recommends \
    git \
    build-essential \
    wget \
    ca-certificates \
    libxml2-dev \
    libssl-dev \
    libcurl4-openssl-dev \
    pkg-config \
    zlib1g-dev \
    libpng-dev \
    libjpeg-dev \
    libfreetype6-dev \
    libonig-dev \
    libzip-dev \
    libicu-dev \
    && rm -rf /var/lib/apt/lists/*

# Install Go
ENV GO_VERSION=1.21.1
RUN wget https://golang.org/dl/go${GO_VERSION}.linux-amd64.tar.gz && \
    tar -C /usr/local -xzf go${GO_VERSION}.linux-amd64.tar.gz && \
    rm go${GO_VERSION}.linux-amd64.tar.gz

# Set Go environment variables
ENV GOROOT=/usr/local/go
ENV GOPATH=/go
ENV PATH=$GOROOT/bin:$GOPATH/bin:$PATH

# Install xcaddy
RUN go install github.com/caddyserver/xcaddy/cmd/xcaddy@latest

# Clone FrankenPHP repository
RUN git clone https://github.com/dunglas/frankenphp.git /src/frankenphp

WORKDIR /src/frankenphp

# Set environment variables for PIE
ENV CGO_ENABLED=1
ENV XCADDY_SETCAP=1
ENV XCADDY_GO_BUILD_FLAGS="-ldflags \"-w -s -extldflags '-Wl,-z,stack-size=0x80000'\""
ENV CGO_CFLAGS="-fPIC" \
    CGO_LDFLAGS="-pie" \
    GOFLAGS="-buildmode=pie"
# Build FrankenPHP with xcaddy
RUN xcaddy build \
    --output /usr/local/bin/frankenphp \
    --with github.com/dunglas/frankenphp \
    --with github.com/dunglas/frankenphp/caddy \
    --with github.com/dunglas/mercure/caddy \
    --with github.com/dunglas/vulcain/caddy \
    --with github.com/darkweak/souin \
    --with github.com/caddyserver/cache-handler

did I understand you correctly ?

109.5 go: downloading cloud.google.com/go/compute v1.24.0
110.3 2024/08/01 07:04:48 [INFO] exec (timeout=0s): /usr/local/go/bin/go build -o /usr/local/bin/frankenphp -ldflags -w -s -extldflags '-Wl,-z,stack-size=0x80000'
127.8 # github.com/dunglas/frankenphp
127.8 frankenphp.c:15:10: fatal error: sapi/embed/php_embed.h: No such file or directory
127.8    15 | #include <sapi/embed/php_embed.h>
127.8       |          ^~~~~~~~~~~~~~~~~~~~~~~~
127.8 compilation terminated.
130.7 2024/08/01 07:05:09 [INFO] Cleaning up temporary folder: /tmp/buildenv_2024-08-01-0702.3424651328
130.7 2024/08/01 07:05:09 [FATAL] exit status 1
------
failed to solve: process "/bin/sh -c xcaddy build     --output /usr/local/bin/frankenphp     --with github.com/dunglas/frankenphp     --with github.com/dunglas/frankenphp/caddy     --with github.com/dunglas/mercure/caddy     --with github.com/dunglas/vulcain/caddy     --with github.com/darkweak/souin     --with github.com/caddyserver/cache-handler" did not complete successfully: exit code: 1
g-ra commented 3 months ago

@withinboredom use frankenphp builder images ? https://github.com/dunglas/frankenphp/issues/944

AlliBalliBaba commented 3 months ago

@g-ra I think he means using the builder image like described here in the docs.