Skip to content

Commit 1da2ba1

Browse files
committed
fix(ci): Docker builds
1 parent 0c25b24 commit 1da2ba1

11 files changed

Lines changed: 42 additions & 28 deletions

File tree

.github/workflows/docker.yaml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@ on:
88
branches:
99
- main
1010
paths:
11-
- "*.c"
12-
- "*.h"
13-
- "*.stub.php"
14-
- "*Dockerfile"
1511
- "docker-bake.hcl"
16-
- "*.sh"
1712
- ".github/workflows/docker.yaml"
13+
- "**cgo.go"
14+
- "**Dockerfile"
15+
- "**.c"
16+
- "**.h"
17+
- "**.sh"
18+
- "**.stub.php"
1819
push:
1920
branches:
2021
- main
@@ -205,7 +206,7 @@ jobs:
205206
run: |
206207
docker run --platform=${{ matrix.platform }} --rm \
207208
"$(jq -r '."builder-${{ matrix.variant }}"."containerimage.config.digest"' <<< "${METADATA}")" \
208-
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 ./...'
209+
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 ./...'
209210
env:
210211
METADATA: ${{ steps.build.outputs.metadata }}
211212
# Adapted from https://docs.docker.com/build/ci/github-actions/multi-platform/

.github/workflows/static.yaml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@ on:
88
branches:
99
- main
1010
paths:
11-
- "*.c"
12-
- "*.h"
13-
- "*.stub.php"
14-
- "*Dockerfile"
1511
- "docker-bake.hcl"
16-
- "*.sh"
17-
- ".github/workflows/static.yaml"
12+
- ".github/workflows/docker.yaml"
13+
- "**cgo.go"
14+
- "**Dockerfile"
15+
- "**.c"
16+
- "**.h"
17+
- "**.sh"
18+
- "**.stub.php"
1819
push:
1920
branches:
2021
- main

Dockerfile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,9 @@ ENV CGO_CFLAGS="-DFRANKENPHP_VERSION=$FRANKENPHP_VERSION $PHP_CFLAGS"
115115
ENV CGO_CPPFLAGS=$PHP_CPPFLAGS
116116
ENV CGO_LDFLAGS="-L/usr/local/lib -lssl -lcrypto -lreadline -largon2 -lcurl -lonig -lz $PHP_LDFLAGS"
117117

118-
RUN echo $CGO_LDFLAGS
119-
120118
WORKDIR /go/src/app/caddy/frankenphp
121-
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 && \
119+
RUN GOBIN=/usr/local/bin \
120+
../../go.sh install -ldflags "-w -s -X 'github.com/caddyserver/caddy/v2.CustomVersion=FrankenPHP $FRANKENPHP_VERSION PHP $PHP_VERSION Caddy'" -buildvcs=true && \
122121
setcap cap_net_bind_service=+ep /usr/local/bin/frankenphp && \
123122
cp Caddyfile /etc/frankenphp/Caddyfile && \
124123
frankenphp version && \

alpine.Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,8 @@ ENV CGO_CPPFLAGS=$PHP_CPPFLAGS
122122
ENV CGO_LDFLAGS="-lssl -lcrypto -lreadline -largon2 -lcurl -lonig -lz $PHP_LDFLAGS"
123123

124124
WORKDIR /go/src/app/caddy/frankenphp
125-
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 && \
125+
RUN GOBIN=/usr/local/bin \
126+
../../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 && \
126127
setcap cap_net_bind_service=+ep /usr/local/bin/frankenphp && \
127128
([ -z "${NO_COMPRESS}" ] && upx --best /usr/local/bin/frankenphp || true) && \
128129
frankenphp version && \

build-static.sh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,6 @@ fi
9090
if [ "${os}" = "linux" ] && { [[ "${arch}" =~ "aarch" ]] || [[ "${arch}" =~ "arm" ]]; }; then
9191
fpic="-fPIC"
9292
fpie="-fPIE"
93-
94-
# FIXME: temporary workaround because pre-built poackages aren't compiled wiht -fPIC yet
95-
SPC_OPT_DOWNLOAD_ARGS="--ignore-cache-sources=php-src --retry 5"
9693
else
9794
fpic="-fpic"
9895
fpie="-fpie"

cgo.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package frankenphp
2+
3+
// #cgo darwin pkg-config: libxml-2.0
4+
// #cgo CFLAGS: -Wall -Werror
5+
// #cgo linux CFLAGS: -D_GNU_SOURCE
6+
// #cgo LDFLAGS: -lphp -lm -lutil
7+
// #cgo linux LDFLAGS: -ldl -lresolv
8+
// #cgo darwin LDFLAGS: -Wl,-rpath,/usr/local/lib -liconv -ldl
9+
import "C"

dev.Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,10 @@ RUN git clone https://github.com/e-dant/watcher . && \
8080
ldconfig
8181

8282
WORKDIR /go/src/app
83-
COPY . .
83+
COPY --link . ./
8484

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

8888
WORKDIR /go/src/app
8989
CMD [ "zsh" ]

frankenphp.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,6 @@ package frankenphp
1414

1515
// #cgo nocallback frankenphp_update_server_context
1616
// #cgo noescape frankenphp_update_server_context
17-
// #cgo darwin pkg-config: libxml-2.0
18-
// #cgo CFLAGS: -Wall -Werror
19-
// #cgo linux CFLAGS: -D_GNU_SOURCE
20-
// #cgo LDFLAGS: -lphp -lm -lutil
21-
// #cgo linux LDFLAGS: -ldl -lresolv
22-
// #cgo darwin LDFLAGS: -Wl,-rpath,/usr/local/lib -liconv -ldl
2317
// #include <stdlib.h>
2418
// #include <stdint.h>
2519
// #include <php_variables.h>

go.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/sh
2+
# Runs the go command with the proper Go and cgo flags.
3+
4+
GOFLAGS="$GOFLAGS -tags=nobadger,nomysql,nopgx" \
5+
CGO_CFLAGS="$CGO_CFLAGS $(php-config --includes)" \
6+
CGO_LDFLAGS="$CGO_LDFLAGS $(php-config --ldflags) $(php-config --libs)" \
7+
go "$@"

internal/watcher/cgo.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//go:build !nowatcher
2+
3+
package watcher
4+
5+
// #cgo LDFLAGS: -lwatcher-c -lstdc++
6+
import "C"

0 commit comments

Comments
 (0)