Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ on:
branches:
- main
paths:
- "*.c"
- "*.h"
- "*.stub.php"
- "*Dockerfile"
- "docker-bake.hcl"
- "*.sh"
- ".github/workflows/docker.yaml"
- "**cgo.go"
- "**Dockerfile"
- "**.c"
- "**.h"
- "**.sh"
- "**.stub.php"
push:
branches:
- main
Expand Down Expand Up @@ -205,7 +206,7 @@ jobs:
run: |
docker run --platform=${{ matrix.platform }} --rm \
"$(jq -r '."builder-${{ matrix.variant }}"."containerimage.config.digest"' <<< "${METADATA}")" \
sh -c 'go test -tags ${{ matrix.race }} -v $(go list ./... | grep -v github.com/dunglas/frankenphp/internal/testext | grep -v github.com/dunglas/frankenphp/internal/extgen) && cd caddy && go test -tags nobadger,nomysql,nopgx ${{ matrix.race }} -v ./...'
sh -c './go.sh test -tags ${{ matrix.race }} -v $(./go.sh list ./... | grep -v github.com/dunglas/frankenphp/internal/testext | grep -v github.com/dunglas/frankenphp/internal/extgen) && cd caddy && ../go.sh test ${{ matrix.race }} -v ./...'
env:
METADATA: ${{ steps.build.outputs.metadata }}
# Adapted from https://docs.docker.com/build/ci/github-actions/multi-platform/
Expand Down
13 changes: 7 additions & 6 deletions .github/workflows/static.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ on:
branches:
- main
paths:
- "*.c"
- "*.h"
- "*.stub.php"
- "*Dockerfile"
- "docker-bake.hcl"
- "*.sh"
- ".github/workflows/static.yaml"
- ".github/workflows/docker.yaml"
- "**cgo.go"
- "**Dockerfile"
- "**.c"
- "**.h"
- "**.sh"
- "**.stub.php"
push:
branches:
- main
Expand Down
5 changes: 2 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,9 @@ ENV CGO_CFLAGS="-DFRANKENPHP_VERSION=$FRANKENPHP_VERSION $PHP_CFLAGS"
ENV CGO_CPPFLAGS=$PHP_CPPFLAGS
ENV CGO_LDFLAGS="-L/usr/local/lib -lssl -lcrypto -lreadline -largon2 -lcurl -lonig -lz $PHP_LDFLAGS"

RUN echo $CGO_LDFLAGS

WORKDIR /go/src/app/caddy/frankenphp
RUN GOBIN=/usr/local/bin go install -tags 'nobadger,nomysql,nopgx' -ldflags "-w -s -X 'github.com/caddyserver/caddy/v2.CustomVersion=FrankenPHP $FRANKENPHP_VERSION PHP $PHP_VERSION Caddy'" -buildvcs=true && \
RUN GOBIN=/usr/local/bin \
../../go.sh install -ldflags "-w -s -X 'github.com/caddyserver/caddy/v2.CustomVersion=FrankenPHP $FRANKENPHP_VERSION PHP $PHP_VERSION Caddy'" -buildvcs=true && \
setcap cap_net_bind_service=+ep /usr/local/bin/frankenphp && \
cp Caddyfile /etc/frankenphp/Caddyfile && \
frankenphp version && \
Expand Down
3 changes: 2 additions & 1 deletion alpine.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ ENV CGO_CPPFLAGS=$PHP_CPPFLAGS
ENV CGO_LDFLAGS="-lssl -lcrypto -lreadline -largon2 -lcurl -lonig -lz $PHP_LDFLAGS"

WORKDIR /go/src/app/caddy/frankenphp
RUN GOBIN=/usr/local/bin go install -tags 'nobadger,nomysql,nopgx' -ldflags "-w -s -extldflags '-Wl,-z,stack-size=0x80000' -X 'github.com/caddyserver/caddy/v2.CustomVersion=FrankenPHP $FRANKENPHP_VERSION PHP $PHP_VERSION Caddy'" -buildvcs=true && \
RUN GOBIN=/usr/local/bin \
../../go.sh install -ldflags "-w -s -extldflags '-Wl,-z,stack-size=0x80000' -X 'github.com/caddyserver/caddy/v2.CustomVersion=FrankenPHP $FRANKENPHP_VERSION PHP $PHP_VERSION Caddy'" -buildvcs=true && \
setcap cap_net_bind_service=+ep /usr/local/bin/frankenphp && \
([ -z "${NO_COMPRESS}" ] && upx --best /usr/local/bin/frankenphp || true) && \
frankenphp version && \
Expand Down
3 changes: 0 additions & 3 deletions build-static.sh
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,6 @@ fi
if [ "${os}" = "linux" ] && { [[ "${arch}" =~ "aarch" ]] || [[ "${arch}" =~ "arm" ]]; }; then
fpic="-fPIC"
fpie="-fPIE"

# FIXME: temporary workaround because pre-built poackages aren't compiled wiht -fPIC yet
SPC_OPT_DOWNLOAD_ARGS="--ignore-cache-sources=php-src --retry 5"
else
fpic="-fpic"
fpie="-fpie"
Expand Down
9 changes: 9 additions & 0 deletions cgo.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package frankenphp

// #cgo darwin pkg-config: libxml-2.0
// #cgo CFLAGS: -Wall -Werror
// #cgo linux CFLAGS: -D_GNU_SOURCE
// #cgo LDFLAGS: -lphp -lm -lutil
// #cgo linux LDFLAGS: -ldl -lresolv
// #cgo darwin LDFLAGS: -Wl,-rpath,/usr/local/lib -liconv -ldl
import "C"
4 changes: 2 additions & 2 deletions dev.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ RUN git clone https://github.com/e-dant/watcher . && \
ldconfig

WORKDIR /go/src/app
COPY . .
COPY --link . ./

WORKDIR /go/src/app/caddy/frankenphp
RUN go build -buildvcs=false -tags 'nobadger,nomysql,nopgx'
RUN ../../go.sh build -buildvcs=false

WORKDIR /go/src/app
CMD [ "zsh" ]
6 changes: 0 additions & 6 deletions frankenphp.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@ package frankenphp

// #cgo nocallback frankenphp_update_server_context
// #cgo noescape frankenphp_update_server_context
// #cgo darwin pkg-config: libxml-2.0
// #cgo CFLAGS: -Wall -Werror
// #cgo linux CFLAGS: -D_GNU_SOURCE
// #cgo LDFLAGS: -lphp -lm -lutil
// #cgo linux LDFLAGS: -ldl -lresolv
// #cgo darwin LDFLAGS: -Wl,-rpath,/usr/local/lib -liconv -ldl
// #include <stdlib.h>
// #include <stdint.h>
// #include <php_variables.h>
Expand Down
7 changes: 7 additions & 0 deletions go.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh
# Runs the go command with the proper Go and cgo flags.

GOFLAGS="$GOFLAGS -tags=nobadger,nomysql,nopgx" \
CGO_CFLAGS="$CGO_CFLAGS $(php-config --includes)" \
CGO_LDFLAGS="$CGO_LDFLAGS $(php-config --ldflags) $(php-config --libs)" \
go "$@"
6 changes: 6 additions & 0 deletions internal/watcher/cgo.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
//go:build !nowatcher

package watcher

// #cgo LDFLAGS: -lwatcher-c -lstdc++
import "C"
1 change: 0 additions & 1 deletion internal/watcher/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

package watcher

// #cgo LDFLAGS: -lwatcher-c -lstdc++
// #include <stdint.h>
// #include <stdlib.h>
// #include "watcher.h"
Expand Down
Loading