compose

package
v0.0.0-...-32c6621 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2026 License: MIT Imports: 44 Imported by: 2

Documentation

Index

Constants

View Source
const (
	MiB                         = 1024 * 1024
	ContextFileLimit            = 100
	ContextSizeSoftLimit        = 10 * MiB
	DefaultContextSizeHardLimit = 100 * MiB
)
View Source
const Mode_HOST = "host"
View Source
const Mode_INGRESS = "ingress"
View Source
const Protocol_TCP = "tcp"
View Source
const Protocol_UDP = "udp"
View Source
const RAILPACK = "*Railpack"

Variables

View Source
var (
	ArchiveTypeZip  = ArchiveType{MimeType: "application/zip", Extension: ".zip"}
	ArchiveTypeGzip = ArchiveType{MimeType: "application/gzip", Extension: ".tar.gz"}
)
View Source
var (
	ContextSizeHardLimit = parseContextLimit(os.Getenv("DEFANG_BUILD_CONTEXT_LIMIT"), DefaultContextSizeHardLimit)
)
View Source
var ErrDockerfileNotFound = errors.New("dockerfile not found")

Functions

func DetectInterpolationVariables

func DetectInterpolationVariables(value string) []string

func FindAllBaseImages

func FindAllBaseImages(project *composeTypes.Project) ([]string, error)

func FixupServices

func FixupServices(ctx context.Context, provider client.Provider, project *composeTypes.Project, upload UploadMode) error

func GetHealthCheckPathAndPort

func GetHealthCheckPathAndPort(hc *types.HealthCheckConfig) (string, int)

func GetImageRepo

func GetImageRepo(image string) string

func GetNumOfGPUs

func GetNumOfGPUs(services composeTypes.Services) int

func IsComputeService

func IsComputeService(service *composeTypes.ServiceConfig) bool

func IsMongoRepo

func IsMongoRepo(repo string) bool

func IsPostgresRepo

func IsPostgresRepo(repo string) bool

func IsRedisRepo

func IsRedisRepo(repo string) bool

func IsReservedConfigName

func IsReservedConfigName(name string) bool

IsReservedConfigName reports whether name is auto-populated by Defang/compose-go and therefore never a config the user has to set.

func IsSecret

func IsSecret(key, value string) (bool, []string, error)

func MarshalYAML

func MarshalYAML(p *Project) ([]byte, error)

func NormalizeServiceName

func NormalizeServiceName(s string) string

func ValidateDockerfile

func ValidateDockerfile(dockerfilePath string, serviceName string) error

ValidateDockerfile validates the syntax and basic structure of a Dockerfile

func ValidateProject

func ValidateProject(project *composeTypes.Project, mode modes.Recipe) error

func ValidateProjectConfig

func ValidateProjectConfig(composeProject *composeTypes.Project, listConfigNames []string) error

func ValidateService

func ValidateService(service *types.ServiceConfig) error

func ValidateServiceDockerfiles

func ValidateServiceDockerfiles(project *Project) error

ValidateServiceDockerfiles validates all Dockerfiles referenced by services in a project

func WalkContextFolder

func WalkContextFolder(root, dockerfile string, fn func(path string, de os.DirEntry, slashPath string) error) error

Types

type ArchiveType

type ArchiveType struct {
	MimeType  MimeType
	Extension string
}

type BuildConfig

type BuildConfig = composeTypes.BuildConfig

type DockerfileValidationError

type DockerfileValidationError struct {
	ServiceName    string
	DockerfilePath string
	Line           int
	Message        string
	Err            error
}

DockerfileValidationError represents an error found during Dockerfile validation

func (*DockerfileValidationError) Error

func (e *DockerfileValidationError) Error() string

func (*DockerfileValidationError) Unwrap

func (e *DockerfileValidationError) Unwrap() error

type DockerfileValidationErrors

type DockerfileValidationErrors struct {
	Errors []error
}

DockerfileValidationErrors represents multiple Dockerfile validation errors

func (*DockerfileValidationErrors) Error

func (*DockerfileValidationErrors) Unwrap

func (e *DockerfileValidationErrors) Unwrap() []error

type ErrConfigInterpolationInBuildArgs

type ErrConfigInterpolationInBuildArgs []string

func (ErrConfigInterpolationInBuildArgs) Error

type ErrConfigInterpolationInModels

type ErrConfigInterpolationInModels []string

func (ErrConfigInterpolationInModels) Error

type ErrMissingConfig

type ErrMissingConfig []string

func (ErrMissingConfig) Error

func (e ErrMissingConfig) Error() string

type FixupTarget

type FixupTarget string
const (
	BuildArgs       FixupTarget = "build argument"
	EnvironmentVars FixupTarget = "environment variable"
)

type ListConfigNamesFunc

type ListConfigNamesFunc func(context.Context) ([]string, error)

type Loader

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

func NewLoader

func NewLoader(opts ...LoaderOption) *Loader

func NewLoaderFromOptions

func NewLoaderFromOptions(options LoaderOptions) *Loader

func (*Loader) CreateProjectForDebug

func (l *Loader) CreateProjectForDebug() (*Project, error)

func (*Loader) LoadProject

func (l *Loader) LoadProject(ctx context.Context) (*Project, error)

func (*Loader) LoadProjectName

func (l *Loader) LoadProjectName(ctx context.Context) (string, bool, error)

func (*Loader) ProjectWorkingDir

func (l *Loader) ProjectWorkingDir(ctx context.Context) (string, error)

func (*Loader) ResolveProjectWorkingDir

func (l *Loader) ResolveProjectWorkingDir(context.Context) (string, error)

ResolveProjectWorkingDir returns the project directory without parsing or caching the Compose project.

type LoaderOption

type LoaderOption func(*LoaderOptions)

func WithDefaultEnvFiles

func WithDefaultEnvFiles(paths ...string) LoaderOption

func WithEnvFiles

func WithEnvFiles(paths ...string) LoaderOption

WithEnvFiles sets the env file(s) used to populate the project environment for interpolation, mirroring `docker compose --env-file`. When empty, the loader falls back to the COMPOSE_ENV_FILES environment variable, and finally to the default PWD/.env file (if present).

func WithInterpolationEnv

func WithInterpolationEnv(env map[string]string) LoaderOption

WithInterpolationEnv adds CLI-supplied values to the Compose interpolation environment. These values take precedence over values from env files.

func WithPath

func WithPath(paths ...string) LoaderOption

func WithProjectName

func WithProjectName(name string) LoaderOption

type LoaderOptions

type LoaderOptions struct {
	ConfigPaths []string
	ProjectName string
	EnvFiles    []string
	// InterpolationEnv contains values supplied by the CLI for Compose
	// interpolation. These values take precedence over values from env files.
	InterpolationEnv map[string]string
	// DefaultEnvFiles are candidate env files (names resolved against the project
	// working directory) tried when no env file was set explicitly (via EnvFiles
	// or COMPOSE_ENV_FILES). Files that don't exist are skipped, and later files
	// override earlier ones. Unlike EnvFiles, these never fail on a missing file.
	DefaultEnvFiles []string
}

type MimeType

type MimeType string

type Project

type Project = composeTypes.Project

func LoadFromContent

func LoadFromContent(ctx context.Context, content []byte, nameFallback string) (*Project, error)

func LoadFromContentWithInterpolation

func LoadFromContentWithInterpolation(ctx context.Context, content []byte, nameFallback string) (*Project, error)

type ServiceConfig

type ServiceConfig = composeTypes.ServiceConfig

type ServiceFixupper

type ServiceFixupper interface {
	FixupServices(ctx context.Context, project *composeTypes.Project) error
}

type ServiceNameReplacer

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

func NewServiceNameReplacer

func NewServiceNameReplacer(ctx context.Context, dnsResolver client.DNSResolver, project *composeTypes.Project) ServiceNameReplacer

func (*ServiceNameReplacer) ContainsPrivateServiceName

func (s *ServiceNameReplacer) ContainsPrivateServiceName(name string) bool

func (*ServiceNameReplacer) ReplaceServiceNameWithDNS

func (s *ServiceNameReplacer) ReplaceServiceNameWithDNS(serviceName string, key, value string, fixupTarget FixupTarget) string

type Services

type Services = composeTypes.Services

type UploadMode

type UploadMode int

*

  • UploadMode determines how the build context tarball is handled when building images: *
  • ServiceConfig | default | --force | --build | --build --force |
  • --------------+-----------+-----------+-----------+-----------------+
  • build | Digest | Force | Digest | Force |
  • image + build | Ignore | Force | Digest | Force |
const (
	UploadModeDefault  UploadMode = iota // the default: like UploadModeDigest, but skip upload if an image was specified
	UploadModeDigest                     // calculate the digest of the tarball so we can skip building the same image twice
	UploadModeForce                      // force: always upload the tarball, even if it's the same as a previous one
	UploadModeIgnore                     // dry-run: don't upload the tarball, just return the path
	UploadModePreview                    // preview: like dry-run but does start the preview command
	UploadModeEstimate                   // cost estimation: like preview, but skips the tarball
)

type WriterFactory

type WriterFactory interface {
	CreateHeader(info fs.FileInfo, slashPath string) (io.Writer, error)
	Close() error
}

Jump to

Keyboard shortcuts

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