Skip to content

Commit 341b024

Browse files
authored
ci: include version in BuildInfo and Prometheus metrics (#1418)
1 parent 432824e commit 341b024

File tree

7 files changed

+54
-54
lines changed

7 files changed

+54
-54
lines changed

.dockerignore

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
1-
# ignored
2-
**/*
3-
4-
# authorized
5-
!**/Caddyfile
6-
!**/*.go
7-
!**/go.*
8-
!**/*.c
9-
!**/*.h
10-
!testdata/*.php
11-
!testdata/*.txt
12-
!build-static.sh
13-
!app.tar
14-
!app_checksum.txt
1+
/caddy/frankenphp/frankenphp
2+
/internal/testserver/testserver
3+
/internal/testcli/testcli
4+
/dist
5+
.DS_Store
6+
.idea/
7+
.vscode/
8+
__debug_bin
9+
frankenphp.test
10+
caddy/frankenphp/Build
11+
*.log

.github/workflows/static.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ jobs:
168168
- name: Run sanity checks
169169
run: |
170170
"${BINARY}" version
171+
"${BINARY}" build-info
171172
"${BINARY}" list-modules | grep frankenphp
172173
"${BINARY}" list-modules | grep http.encoders.br
173174
"${BINARY}" list-modules | grep http.handlers.mercure
@@ -262,6 +263,7 @@ jobs:
262263
- name: Run sanity checks
263264
run: |
264265
"${BINARY}" version
266+
"${BINARY}" build-info
265267
"${BINARY}" list-modules | grep frankenphp
266268
"${BINARY}" list-modules | grep http.encoders.br
267269
"${BINARY}" list-modules | grep http.handlers.mercure

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
/internal/testserver/testserver
33
/internal/testcli/testcli
44
/dist
5+
.DS_Store
56
.idea/
67
.vscode/
78
__debug_bin
89
frankenphp.test
10+
caddy/frankenphp/Build
11+
*.log

Dockerfile

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ ENV PATH=/usr/local/go/bin:$PATH
6161
# This is required to link the FrankenPHP binary to the PHP binary
6262
RUN apt-get update && \
6363
apt-get -y --no-install-recommends install \
64-
cmake \
64+
cmake \
65+
git \
6566
libargon2-dev \
6667
libbrotli-dev \
6768
libcurl4-openssl-dev \
@@ -75,21 +76,6 @@ RUN apt-get update && \
7576
&& \
7677
apt-get clean
7778

78-
WORKDIR /go/src/app
79-
80-
COPY --link go.mod go.sum ./
81-
RUN go mod graph | awk '{if ($1 !~ "@") print $2}' | xargs go get
82-
83-
WORKDIR /go/src/app/caddy
84-
COPY --link caddy/go.mod caddy/go.sum ./
85-
RUN go mod graph | awk '{if ($1 !~ "@") print $2}' | xargs go get
86-
87-
WORKDIR /go/src/app
88-
COPY --link *.* ./
89-
COPY --link caddy caddy
90-
COPY --link internal internal
91-
COPY --link testdata testdata
92-
9379
# Install e-dant/watcher (necessary for file watching)
9480
WORKDIR /usr/local/src/watcher
9581
RUN curl -s https://api.github.com/repos/e-dant/watcher/releases/latest | \
@@ -104,6 +90,18 @@ RUN curl -s https://api.github.com/repos/e-dant/watcher/releases/latest | \
10490
cmake --install build && \
10591
ldconfig
10692

93+
WORKDIR /go/src/app
94+
95+
COPY --link go.mod go.sum ./
96+
RUN go mod graph | awk '{if ($1 !~ "@") print $2}' | xargs go get
97+
98+
WORKDIR /go/src/app/caddy
99+
COPY --link caddy/go.mod caddy/go.sum ./
100+
RUN go mod graph | awk '{if ($1 !~ "@") print $2}' | xargs go get
101+
102+
WORKDIR /go/src/app
103+
COPY --link . ./
104+
107105
# See https://github.com/docker-library/php/blob/master/8.3/bookworm/zts/Dockerfile#L57-L59 for PHP values
108106
ENV CGO_CFLAGS="-DFRANKENPHP_VERSION=$FRANKENPHP_VERSION $PHP_CFLAGS"
109107
ENV CGO_CPPFLAGS=$PHP_CPPFLAGS
@@ -112,10 +110,11 @@ ENV CGO_LDFLAGS="-L/usr/local/lib -lssl -lcrypto -lreadline -largon2 -lcurl -lon
112110
RUN echo $CGO_LDFLAGS
113111

114112
WORKDIR /go/src/app/caddy/frankenphp
115-
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'" && \
113+
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 && \
116114
setcap cap_net_bind_service=+ep /usr/local/bin/frankenphp && \
117115
cp Caddyfile /etc/caddy/Caddyfile && \
118-
frankenphp version
116+
frankenphp version && \
117+
frankenphp build-info
119118

120119
WORKDIR /go/src/app
121120

@@ -133,4 +132,5 @@ RUN apt-get install -y --no-install-recommends libstdc++6 && \
133132

134133
COPY --from=builder /usr/local/bin/frankenphp /usr/local/bin/frankenphp
135134
RUN setcap cap_net_bind_service=+ep /usr/local/bin/frankenphp && \
136-
frankenphp version
135+
frankenphp version && \
136+
frankenphp build-info

alpine.Dockerfile

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -82,21 +82,6 @@ RUN apk add --no-cache --virtual .build-deps \
8282
sqlite-dev \
8383
upx
8484

85-
WORKDIR /go/src/app
86-
87-
COPY --link go.mod go.sum ./
88-
RUN go mod graph | awk '{if ($1 !~ "@") print $2}' | xargs go get
89-
90-
WORKDIR /go/src/app/caddy
91-
COPY caddy/go.mod caddy/go.sum ./
92-
RUN go mod graph | awk '{if ($1 !~ "@") print $2}' | xargs go get
93-
94-
WORKDIR /go/src/app
95-
COPY --link *.* ./
96-
COPY --link caddy caddy
97-
COPY --link internal internal
98-
COPY --link testdata testdata
99-
10085
# Install e-dant/watcher (necessary for file watching)
10186
WORKDIR /usr/local/src/watcher
10287
RUN curl -s https://api.github.com/repos/e-dant/watcher/releases/latest | \
@@ -110,16 +95,29 @@ RUN curl -s https://api.github.com/repos/e-dant/watcher/releases/latest | \
11095
cmake --build build && \
11196
cmake --install build
11297

98+
WORKDIR /go/src/app
99+
100+
COPY --link go.mod go.sum ./
101+
RUN go mod graph | awk '{if ($1 !~ "@") print $2}' | xargs go get
102+
103+
WORKDIR /go/src/app/caddy
104+
COPY caddy/go.mod caddy/go.sum ./
105+
RUN go mod graph | awk '{if ($1 !~ "@") print $2}' | xargs go get
106+
107+
WORKDIR /go/src/app
108+
COPY --link . ./
109+
113110
# See https://github.com/docker-library/php/blob/master/8.3/alpine3.20/zts/Dockerfile#L53-L55
114111
ENV CGO_CFLAGS="-DFRANKENPHP_VERSION=$FRANKENPHP_VERSION $PHP_CFLAGS"
115112
ENV CGO_CPPFLAGS=$PHP_CPPFLAGS
116113
ENV CGO_LDFLAGS="-lssl -lcrypto -lreadline -largon2 -lcurl -lonig -lz $PHP_LDFLAGS"
117114

118115
WORKDIR /go/src/app/caddy/frankenphp
119-
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'" && \
116+
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 && \
120117
setcap cap_net_bind_service=+ep /usr/local/bin/frankenphp && \
121118
([ -z "${NO_COMPRESS}" ] && upx --best /usr/local/bin/frankenphp || true) && \
122-
frankenphp version
119+
frankenphp version && \
120+
frankenphp build-info
123121

124122
WORKDIR /go/src/app
125123

@@ -135,4 +133,5 @@ RUN apk add --no-cache libstdc++ && \
135133

136134
COPY --from=builder /usr/local/bin/frankenphp /usr/local/bin/frankenphp
137135
RUN setcap cap_net_bind_service=+ep /usr/local/bin/frankenphp && \
138-
frankenphp version
136+
frankenphp version && \
137+
frankenphp build-info

build-static.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,7 @@ if type "upx" >/dev/null 2>&1 && [ -z "${DEBUG_SYMBOLS}" ] && [ -z "${NO_COMPRES
323323
fi
324324

325325
"dist/${bin}" version
326+
"dist/${bin}" build-info
326327

327328
if [ -n "${RELEASE}" ]; then
328329
gh release upload "v${FRANKENPHP_VERSION}" "dist/${bin}" --repo dunglas/frankenphp --clobber

static-builder.Dockerfile

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,7 @@ COPY caddy/go.mod caddy/go.sum ./
8888
RUN go mod graph | awk '{if ($1 !~ "@") print $2}' | xargs go get
8989

9090
WORKDIR /go/src/app
91-
COPY --link *.* ./
92-
COPY --link caddy caddy
93-
COPY --link internal internal
91+
COPY --link . ./
9492

9593
RUN --mount=type=secret,id=github-token GITHUB_TOKEN=$(cat /run/secrets/github-token) ./build-static.sh && \
9694
rm -Rf dist/static-php-cli/source/*

0 commit comments

Comments
 (0)