Skip to content

Commit f3fd052

Browse files
committed
initial commit
Signed-off-by: Robert Landers <landers.robert@gmail.com>
1 parent 51da0a7 commit f3fd052

File tree

25 files changed

+662
-65
lines changed

25 files changed

+662
-65
lines changed

cli/Makefile

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,25 @@
1-
TARGET := dphp-linux-*
2-
BIN_PATH := ../bin
3-
DOCKER_IMAGE := builder
4-
DOCKER_TARGET := cli-base-alpine
5-
BUILD_PATH := /go/src/app/cli/dist
1+
# Variables
2+
PHP_INCLUDES := $(shell php-config --includes)
3+
PHP_LDFLAGS := $(shell php-config --ldflags)
4+
PHP_LIBS := $(shell php-config --libs)
65

7-
${BIN_PATH}/${TARGET}: cli.go */* go.mod build.sh build-php.sh ../Dockerfile
8-
mkdir -p ${BIN_PATH}
9-
cd .. && docker buildx build --pull --load --target ${DOCKER_TARGET} -t ${DOCKER_IMAGE} .
10-
docker create --name ${DOCKER_IMAGE} ${DOCKER_IMAGE} || ( docker rm -f ${DOCKER_IMAGE} && false )
11-
docker cp ${DOCKER_IMAGE}:${BUILD_PATH}/dphp ${BIN_PATH}/ || ( docker rm -f ${DOCKER_IMAGE} && false )
12-
docker rm -f ${DOCKER_IMAGE}
13-
upx -9 --force-pie ../bin/dphp-*
6+
XCADDY_FLAGS := -ldflags='-w -s' -tags=nobadger,nomysql,nopgx,nodphp,nobrotli
147

15-
../dist: ${BIN_PATH}/${TARGET}
16-
docker create --name builder builder
17-
docker cp ${DOCKER_IMAGE}:${BUILD_PATH} ../dist
8+
LOCAL_MODULE := /home/withinboredom/code/durable-php/cli
9+
10+
# Targets
11+
frankenphp: ext/build/ext.go
12+
CGO_ENABLED=1 \
13+
XCADDY_GO_BUILD_FLAGS="$(XCADDY_FLAGS)" \
14+
CGO_CFLAGS="$(PHP_INCLUDES)" \
15+
CGO_LDFLAGS="$(PHP_LDFLAGS) $(PHP_LIBS)" \
16+
xcaddy build \
17+
--output frankenphp \
18+
--with github.com/dunglas/frankenphp/caddy \
19+
--with github.com/bottledcode/durable-php/cli=$(LOCAL_MODULE)
20+
21+
ext/build/ext.go: ext/ext.go
22+
GEN_STUB_SCRIPT=/home/withinboredom/code/php-src/build/gen_stub.php \
23+
frankenphp extension-init ext/ext.go
24+
25+
.PHONY: frankenphp

cli/auth/keys.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ package auth
22

33
import (
44
"context"
5-
"durable_php/appcontext"
6-
"durable_php/config"
75
"encoding/base64"
86
"errors"
97
"fmt"
8+
"github.com/bottledcode/durable-php/cli/appcontext"
9+
"github.com/bottledcode/durable-php/cli/config"
1010
"github.com/golang-jwt/jwt/v4"
1111
"net/http"
1212
"strings"

cli/auth/keys_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ package auth
22

33
import (
44
"context"
5-
"durable_php/appcontext"
6-
"durable_php/config"
5+
"github.com/bottledcode/durable-php/cli/appcontext"
6+
"github.com/bottledcode/durable-php/cli/config"
77
"testing"
88
)
99

cli/auth/resource.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ package auth
22

33
import (
44
"context"
5-
"durable_php/appcontext"
6-
"durable_php/glue"
7-
"durable_php/ids"
85
"encoding/json"
96
"errors"
107
"fmt"
8+
"github.com/bottledcode/durable-php/cli/appcontext"
9+
"github.com/bottledcode/durable-php/cli/glue"
10+
"github.com/bottledcode/durable-php/cli/ids"
1111
"github.com/nats-io/nats.go/jetstream"
1212
"go.uber.org/zap"
1313
"net/http"

cli/auth/resourceManager.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ package auth
22

33
import (
44
"context"
5-
"durable_php/appcontext"
6-
"durable_php/glue"
7-
"durable_php/ids"
85
"encoding/json"
6+
"github.com/bottledcode/durable-php/cli/appcontext"
7+
"github.com/bottledcode/durable-php/cli/glue"
8+
"github.com/bottledcode/durable-php/cli/ids"
99
"github.com/modern-go/concurrent"
1010
"github.com/nats-io/nats.go"
1111
"github.com/nats-io/nats.go/jetstream"

cli/auth/resource_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ package auth
22

33
import (
44
"context"
5-
"durable_php/appcontext"
65
"errors"
6+
"github.com/bottledcode/durable-php/cli/appcontext"
77
"github.com/stretchr/testify/assert"
88
"testing"
99
"time"

cli/auth/user.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package auth
22

33
import (
44
"context"
5-
"durable_php/appcontext"
5+
"github.com/bottledcode/durable-php/cli/appcontext"
66
"slices"
77
)
88

cli/cli.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build !nodphp
2+
13
/*
24
* Copyright ©2024 Robert Landers
35
*
@@ -24,14 +26,14 @@ package main
2426

2527
import (
2628
"context"
27-
"durable_php/auth"
28-
"durable_php/config"
29-
"durable_php/glue"
30-
"durable_php/ids"
31-
di "durable_php/init"
32-
"durable_php/lib"
3329
"encoding/json"
3430
"fmt"
31+
"github.com/bottledcode/durable-php/cli/auth"
32+
"github.com/bottledcode/durable-php/cli/config"
33+
"github.com/bottledcode/durable-php/cli/glue"
34+
"github.com/bottledcode/durable-php/cli/ids"
35+
di "github.com/bottledcode/durable-php/cli/init"
36+
"github.com/bottledcode/durable-php/cli/lib"
3537
"github.com/dunglas/frankenphp"
3638
"github.com/nats-io/nats-server/v2/server"
3739
"github.com/nats-io/nats-server/v2/test"

cli/export.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
//go:build nodphp
2+
3+
package cli
4+
5+
import _ "github.com/bottledcode/durable-php/cli/ext/build"

0 commit comments

Comments
 (0)