Skip to content

Commit e79ff30

Browse files
committed
ci: include version in BuildInfo and Prometheus metrics
1 parent f50248a commit e79ff30

5 files changed

Lines changed: 39 additions & 50 deletions

File tree

.dockerignore

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
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+
.idea/
6+
.vscode/
7+
__debug_bin
8+
frankenphp.test
9+
caddy/frankenphp/Build

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@
66
.vscode/
77
__debug_bin
88
frankenphp.test
9+
caddy/frankenphp/Build

Dockerfile

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ ENV PATH=/usr/local/go/bin:$PATH
6262
RUN apt-get update && \
6363
apt-get -y --no-install-recommends install \
6464
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+
ADD --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,7 +110,7 @@ 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 git status && 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 && \
118116
frankenphp version

alpine.Dockerfile

Lines changed: 13 additions & 16 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,13 +95,25 @@ 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+
ADD --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) && \
122119
frankenphp version

static-builder.Dockerfile

Lines changed: 2 additions & 4 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+
ADD --link . ./
9492

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

0 commit comments

Comments
 (0)