generated from TBD54566975/tbd-project-template
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add
ftl box --compose
flag (#1915)
The `--compose` flag writes a completely self-contained Docker compose file that starts PG + ftl-in-a-box. Also: - Modified BuildEngine.Graph() to pull dependencies from the schema as well, because that's all we have in the box. - Added an integration test. > [!WARNING] > Until #1887 is integrated, config/secrets can't be used, and once that lands `ftl box` will need to switch to an alternate config/secret resolver.
- Loading branch information
1 parent
2b5a667
commit ff7375c
Showing
17 changed files
with
454 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
//go:build integration | ||
|
||
package main | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/alecthomas/assert/v2" | ||
|
||
. "github.com/TBD54566975/ftl/integration" | ||
"github.com/TBD54566975/ftl/internal/exec" | ||
"github.com/TBD54566975/ftl/internal/log" | ||
) | ||
|
||
func TestBox(t *testing.T) { | ||
// Need a longer timeout to wait for FTL inside Docker. | ||
t.Setenv("FTL_INTEGRATION_TEST_TIMEOUT", "30s") | ||
Infof("Building local ftl0/ftl-box:latest Docker image") | ||
ctx := log.ContextWithNewDefaultLogger(context.Background()) | ||
err := exec.Command(ctx, log.Debug, "../..", "docker", "build", "-t", "ftl0/ftl-box:latest", "--progress=plain", "--platform=linux/amd64", "-f", "Dockerfile.box", ".").Run() | ||
assert.NoError(t, err) | ||
RunWithoutController(t, "", | ||
CopyModule("time"), | ||
CopyModule("echo"), | ||
Exec("ftl", "box", "echo", "--compose=echo-compose.yml"), | ||
Exec("docker", "compose", "-f", "echo-compose.yml", "up", "--wait"), | ||
Call("echo", "echo", Obj{"name": "Alice"}, nil), | ||
Exec("docker", "compose", "-f", "echo-compose.yml", "down", "--rmi", "local"), | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// This is the echo module. | ||
package echo | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"ftl/time" | ||
|
||
"github.com/TBD54566975/ftl/go-runtime/ftl" | ||
) | ||
|
||
// An echo request. | ||
type EchoRequest struct { | ||
Name ftl.Option[string] `json:"name"` | ||
} | ||
|
||
type EchoResponse struct { | ||
Message string `json:"message"` | ||
} | ||
|
||
// Echo returns a greeting with the current time. | ||
// | ||
//ftl:verb | ||
func Echo(ctx context.Context, req EchoRequest) (EchoResponse, error) { | ||
tresp, err := ftl.Call(ctx, time.Time, time.TimeRequest{}) | ||
if err != nil { | ||
return EchoResponse{}, err | ||
} | ||
|
||
return EchoResponse{Message: fmt.Sprintf("Hello, %s!!! It is %s!", req.Name.Default("world"), tresp.Time)}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module = "echo" | ||
language = "go" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
module ftl/echo | ||
|
||
go 1.22.2 | ||
|
||
replace github.com/TBD54566975/ftl => ../../../../.. | ||
|
||
require github.com/TBD54566975/ftl v0.248.0 | ||
|
||
require ( | ||
connectrpc.com/connect v1.16.1 // indirect | ||
connectrpc.com/grpcreflect v1.2.0 // indirect | ||
connectrpc.com/otelconnect v0.7.0 // indirect | ||
github.com/alecthomas/atomic v0.1.0-alpha2 // indirect | ||
github.com/alecthomas/concurrency v0.0.2 // indirect | ||
github.com/alecthomas/participle/v2 v2.1.1 // indirect | ||
github.com/alecthomas/types v0.16.0 // indirect | ||
github.com/alessio/shellescape v1.4.2 // indirect | ||
github.com/danieljoos/wincred v1.2.0 // indirect | ||
github.com/go-logr/logr v1.4.2 // indirect | ||
github.com/go-logr/stdr v1.2.2 // indirect | ||
github.com/godbus/dbus/v5 v5.1.0 // indirect | ||
github.com/jackc/pgpassfile v1.0.0 // indirect | ||
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect | ||
github.com/jackc/pgx/v5 v5.6.0 // indirect | ||
github.com/jackc/puddle/v2 v2.2.1 // indirect | ||
github.com/jpillora/backoff v1.0.0 // indirect | ||
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect | ||
github.com/mattn/go-isatty v0.0.20 // indirect | ||
github.com/multiformats/go-base36 v0.2.0 // indirect | ||
github.com/puzpuzpuz/xsync/v3 v3.2.0 // indirect | ||
github.com/swaggest/jsonschema-go v0.3.72 // indirect | ||
github.com/swaggest/refl v1.3.0 // indirect | ||
github.com/zalando/go-keyring v0.2.5 // indirect | ||
go.opentelemetry.io/otel v1.27.0 // indirect | ||
go.opentelemetry.io/otel/metric v1.27.0 // indirect | ||
go.opentelemetry.io/otel/trace v1.27.0 // indirect | ||
golang.org/x/crypto v0.24.0 // indirect | ||
golang.org/x/exp v0.0.0-20240604190554-fc45aab8b7f8 // indirect | ||
golang.org/x/mod v0.18.0 // indirect | ||
golang.org/x/net v0.26.0 // indirect | ||
golang.org/x/sync v0.7.0 // indirect | ||
golang.org/x/sys v0.21.0 // indirect | ||
golang.org/x/text v0.16.0 // indirect | ||
google.golang.org/protobuf v1.34.2 // indirect | ||
) |
Oops, something went wrong.