Documentation
¶
Overview ¶
Package compose runs docker compose and reads the normalised configuration it prints. siding never parses a compose file itself: interpolation, profiles, include and extends are Compose's business.
Index ¶
Constants ¶
const MinVersion = "2.24"
MinVersion is the oldest Compose siding works with: `ports: !reset []` needs 2.24.
Variables ¶
var FileNames = []string{"compose.yaml", "compose.yml", "docker-compose.yaml", "docker-compose.yml"}
FileNames are the compose files Compose itself looks for, in its order.
Functions ¶
Types ¶
type CLI ¶
type CLI struct {
// Binary is the docker executable; empty means "docker".
Binary string
// contains filtered or unexported fields
}
CLI runs docker compose. Its zero value uses "docker" from PATH.
func (*CLI) Run ¶
func (c *CLI) Run(ctx context.Context, inv Invocation, args []string, stdout, stderr io.Writer) error
Run runs docker compose with args, streaming its output. On failure the error carries the last lines Compose printed on stderr.
func (*CLI) UnresolvedConfig ¶
UnresolvedConfig prints the normalised configuration without reading env files, so it succeeds even when an env_file is missing; EnvFiles reads their paths from it.
type Invocation ¶
type Invocation struct {
// Dir is the working directory; Compose's project directory is the first file's.
Dir string
Project string
// Files are passed as -f, in order. Without files, Compose acts on the project by name.
Files []string
}
Invocation names a Compose project and the files it is made of.
type Project ¶
type Project struct {
Name string
Services map[string]Service
Networks map[string]Resource
Volumes map[string]Resource
}
Project is the part of a normalised compose configuration siding needs.
func ParseConfig ¶
ParseConfig reads the output of docker compose config --format json.
func (*Project) ServiceNames ¶
ServiceNames returns the service names in the order Compose prints them (sorted).
type Service ¶
type Service struct {
// Ports are the distinct container ports from ports (targets) and expose, ascending.
Ports []int
// Published are the ports the compose file publishes on the host.
Published []int
Labels map[string]string
Networks []string // keys of the service's networks, sorted
NetworkMode string
Environment map[string]string
ContainerName string
// Binds are the absolute host paths of the service's bind mounts.
Binds []string
// Volumes are the keys of the named volumes the service mounts.
Volumes []string
// Healthcheck is set when the compose file gives the service a healthcheck. One from the
// image is not visible here.
Healthcheck bool
// MemoryLimit is deploy.resources.limits.memory, else mem_limit, in bytes; 0 for none.
MemoryLimit int64
// Replicas is deploy.replicas, else scale, else 1.
Replicas int
// Build is set when the service is built from a Dockerfile.
Build bool
}
Service is one service of a Project.
type TailBuffer ¶
type TailBuffer struct {
Max int
// contains filtered or unexported fields
}
TailBuffer keeps the last Max lines written to it.
func (*TailBuffer) Lines ¶
func (t *TailBuffer) Lines() []string
Lines returns the kept lines, the unfinished last one included.
func (*TailBuffer) String ¶
func (t *TailBuffer) String() string