Skip to content

Commit

Permalink
feat: add FrankenPHP version to the version command
Browse files Browse the repository at this point in the history
  • Loading branch information
dunglas committed Jul 17, 2023
1 parent 6c215b8 commit 54beb05
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
17 changes: 8 additions & 9 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ jobs:
version: latest

- name: Create variants matrix
id: matrix
id: matrix
run: |
METADATA=$(docker buildx bake --print)
METADATA=$(docker buildx bake --print | jq -c)
echo "metadata=$METADATA" >> "$GITHUB_OUTPUT"
echo "variants=$(jq -c '.group.default.targets|map(sub("runner-|builder-"; ""))|unique' <<< $METADATA)" >> "$GITHUB_OUTPUT"
echo "platforms=$(jq -c 'first(.target[]) | .platforms' <<< $METADATA)" >> "$GITHUB_OUTPUT"
echo "metadata=$(jq -c <<< $METADATA)" >> "$GITHUB_OUTPUT"
env:
LATEST: '1' # TODO: unset this variable when releasing the first tagged version
SHA: ${{github.sha}}
Expand Down Expand Up @@ -83,6 +83,7 @@ jobs:
uses: docker/bake-action@v3
with:
pull: true
load: ${{!fromJson(needs.prepare.outputs.push)}}
targets: |
builder-${{matrix.variant}}
runner-${{matrix.variant}}
Expand All @@ -93,7 +94,7 @@ jobs:
*.cache-from=type=gha,scope=${{github.ref}}-${{matrix.platform}}
*.cache-from=type=gha,scope=refs/heads/main-${{matrix.platform}}
*.cache-to=type=gha,scope=${{github.ref}}-${{matrix.platform}}
*.output=type=image,name=dunglas/frankenphp,push-by-digest=true,name-canonical=true,push=${{ needs.prepare.outputs.push }}
${{fromJson(needs.prepare.outputs.push) && '*.output=type=image,name=dunglas/frankenphp,push-by-digest=true,name-canonical=true,push=true' || ''}}
env:
LATEST: '1' # TODO: unset this variable when releasing the first tagged version
SHA: ${{github.sha}}
Expand Down Expand Up @@ -133,11 +134,11 @@ jobs:

- name: Run tests
if: '!matrix.qemu'
continue-on-error: true
continue-on-error: ${{fromJson(needs.prepare.outputs.push)}}
run: |
docker run --platform=${{matrix.platform}} --rm \
dunglas/frankenphp@$(jq -r '."builder-${{matrix.variant}}"."containerimage.digest"' <<< $METADATA) \
"sh -c 'go test ${{matrix.race}} -v ./... && cd caddy && go test ${{matrix.race}} -v ./...'"
$(jq -r '."builder-${{matrix.variant}}"."containerimage.config.digest"' <<< $METADATA) \
"sh -c 'frankenphp version && go test ${{matrix.race}} -v ./... && cd caddy && go test ${{matrix.race}} -v ./...'"
env:
METADATA: ${{steps.build.outputs.metadata}}

Expand All @@ -160,8 +161,6 @@ jobs:
name: metadata-${{matrix.target}}-${{matrix.variant}}
path: /tmp/metadata

- run: ls -R /tmp/metadata

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
Expand Down
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# syntax=docker/dockerfile:1
FROM php-base AS builder

ARG FRANKENPHP_VERSION='dev'

COPY --from=golang-base /usr/local/go/bin/go /usr/local/bin/go
COPY --from=golang-base /usr/local/go /usr/local/go

Expand Down Expand Up @@ -40,7 +42,7 @@ COPY testdata testdata
ENV CGO_LDFLAGS="-lssl -lcrypto -lreadline -largon2 -lcurl -lonig -lz $PHP_LDFLAGS" CGO_CFLAGS=$PHP_CFLAGS CGO_CPPFLAGS=$PHP_CPPFLAGS

RUN cd caddy/frankenphp && \
go build && \
go build -ldflags "-X 'github.com/caddyserver/caddy/v2.CustomVersion=FrankenPHP $FRANKENPHP_VERSION Caddy'" && \
cp frankenphp /usr/local/bin && \
cp /go/src/app/caddy/frankenphp/Caddyfile /etc/Caddyfile

Expand Down
6 changes: 4 additions & 2 deletions alpine.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# syntax=docker/dockerfile:1
FROM php-base AS builder

ARG FRANKENPHP_VERSION='dev'

COPY --from=golang-base /usr/local/go/bin/go /usr/local/bin/go
COPY --from=golang-base /usr/local/go /usr/local/go

Expand Down Expand Up @@ -39,8 +41,8 @@ COPY testdata testdata
ENV CGO_LDFLAGS="-lssl -lcrypto -lreadline -largon2 -lcurl -lonig -lz $PHP_LDFLAGS" CGO_CFLAGS=$PHP_CFLAGS CGO_CPPFLAGS=$PHP_CPPFLAGS

RUN cd caddy/frankenphp && \
go build && \
cp frankenphp /usr/local/bin && \
go build -ldflags "-X 'github.com/caddyserver/caddy/v2.CustomVersion=FrankenPHP $FRANKENPHP_VERSION Caddy'" && \
cp frankenphp /usr/local/bin && \
cp /go/src/app/caddy/frankenphp/Caddyfile /etc/Caddyfile

ENTRYPOINT ["/bin/sh","-c"]
Expand Down
3 changes: 3 additions & 0 deletions docker-bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,7 @@ target "default" {
"org.opencontainers.image.version" = VERSION
"org.opencontainers.image.revision" = SHA
}
args = {
FRANKENPHP_VERSION = VERSION
}
}

0 comments on commit 54beb05

Please sign in to comment.