compose

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 4, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Compose

type Compose struct {
	// contains filtered or unexported fields
}

Compose wraps a Docker Compose project as a scaffold service.

func New

func New(name string, options ...Option) (*Compose, error)

New creates a Compose-backed scaffold service.

func (*Compose) Cleanup

func (c *Compose) Cleanup(ctx context.Context) error

Cleanup runs docker compose down for the configured project.

func (*Compose) Create

func (c *Compose) Create(ctx context.Context) error

Create starts the Compose project. If Compose fails after creating partial resources, Create attempts to clean them up before returning the error.

func (*Compose) Down

func (c *Compose) Down(ctx context.Context) error

Down removes resources for this Compose project, including resources created by an earlier process using the same project name.

func (*Compose) IsRunning

func (c *Compose) IsRunning(ctx context.Context) (bool, error)

IsRunning returns true when any discovered Compose container is running.

func (*Compose) Logs

func (c *Compose) Logs(ctx context.Context) (logs.LogStreams, error)

Logs returns one Docker log stream per discovered Compose service container.

func (*Compose) Name

func (c *Compose) Name() string

func (*Compose) Project

func (c *Compose) Project() string

func (*Compose) Resources

func (c *Compose) Resources(ctx context.Context) (scaffold.ResourceStatus, error)

Resources discovers containers, networks, and volumes by Compose project label. This works across process restarts as long as the project name is stable.

type Option

type Option func(*Compose)

Option configures a Compose service.

func WithBinary

func WithBinary(binary string, argsPrefix ...string) Option

WithBinary overrides the Compose command. The default is docker compose.

func WithEmbeddedFile

func WithEmbeddedFile(name string, content []byte) Option

WithEmbeddedFile adds Compose file contents compiled into the Go binary, usually from go:embed.

func WithFile

func WithFile(path string) Option

WithFile adds a Compose file from disk.

func WithProject

func WithProject(project string) Option

WithProject sets the Docker Compose project name used for commands and label-based discovery.

func WithReadyCheck

func WithReadyCheck(ready Ready) Option

WithReadyCheck adds an application-level readiness check after Compose up.

func WithWaitTimeout

func WithWaitTimeout(timeout time.Duration) Option

WithWaitTimeout configures the default docker compose --wait timeout.

func WithoutWait

func WithoutWait() Option

WithoutWait disables docker compose --wait. Create returns when Compose finishes creating containers.

type Ready

type Ready func(context.Context, *Compose) error

Ready is an optional check that runs after Compose has finished starting the project. Use it for application-level readiness that is not represented by Compose healthchecks.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL