Documentation
¶
Index ¶
Constants ¶
const ( ConditionStarted = "service_started" ConditionHealthy = "service_healthy" ConditionCompletedSuccess = "service_completed_successfully" )
Service startup conditions accepted by the long form of `depends_on`.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Args ¶
Args is Compose's `build.args` block. It always marshals as the map form; the unmarshaler accepts both forms so a hand-written list-form entry (`args: [KEY=VAL]`) survives the round-trip.
type Build ¶
type Build struct {
Context string `yaml:"context"`
Dockerfile string `yaml:"dockerfile"`
Args Args `yaml:"args,omitempty"`
Extra map[string]any `yaml:",inline"`
}
Build describes how a service's image is built. It points at the dev or prod Dockerfile produced by the docker package, relative to Context.
Extra preserves build keys this model does not type (`target`, `labels`, ...).
type Compose ¶
type Compose struct {
Services map[string]*Service `yaml:"services"`
Volumes map[string]*Volume `yaml:"volumes,omitempty"`
Extra map[string]any `yaml:",inline"`
}
Compose is the root document of a docker-compose file. Modern Compose no longer requires a top-level `version:` key, so it is intentionally omitted.
Extra is an inline catch-all for top-level keys this model does not type explicitly (`networks:`, `configs:`, `x-*` extensions, ...). It lets an existing compose file be re-rendered without discarding hand-written configuration.
type Dependency ¶
Dependency is one entry of a service's `depends_on`. Condition is optional: when empty the dependency is emitted as a bare service name, otherwise it carries one of the Condition* startup conditions.
type DependsOn ¶
type DependsOn []Dependency
DependsOn is the ordered set of services a service depends on.
Compose accepts two syntaxes for `depends_on`, and DependsOn handles both: the short list form while every dependency is condition-less, and the long map form as soon as any dependency carries a condition.
func (DependsOn) MarshalYAML ¶
MarshalYAML renders DependsOn in the short list form when no dependency sets a condition, and in the long map form otherwise. In the long form a missing condition falls back to ConditionStarted, which Compose requires there.
type DockerCompose ¶
type DockerCompose struct {
// contains filtered or unexported fields
}
DockerCompose regenerates the project's docker-compose files from the services currently scaffolded under rootPath.
func New ¶
func New(rootPath string, usesDoppler bool, services map[string]projectcfg.ServiceConfig) *DockerCompose
New builds a DockerCompose synchroniser. services records per-service settings — notably the database engine — so the generator can decide whether to scaffold a `<svc>-db` sidecar and a `depends_on` link to it.
func (*DockerCompose) Initialize ¶
func (d *DockerCompose) Initialize() error
Initialize regenerates docker-compose.dev.yaml and docker-compose.yaml from the services discovered under the project root.
Existing files are merged, not overwritten: for a managed service only its build block is refreshed, while manually edited fields, hand-added services and unrecognised top-level keys are preserved.
type EnvFileEntry ¶
EnvFileEntry is one entry of a service's `env_file` list, in Compose's long form. `required: false` is emitted unconditionally so `docker compose down` / `logs` keep working before the secrets file has ever been fetched.
type Healthcheck ¶
type Healthcheck struct {
Test []string `yaml:"test"`
Interval string `yaml:"interval,omitempty"`
Timeout string `yaml:"timeout,omitempty"`
Retries int `yaml:"retries,omitempty"`
StartPeriod string `yaml:"start_period,omitempty"`
}
Healthcheck is Compose's per-service health probe.
type Port ¶
type Port string
Port is a `host:container` port mapping. It always marshals as a quoted scalar — e.g. "8003:8003" — so the colon is never reinterpreted as a YAML mapping key or, by stricter YAML 1.1 parsers, as a base-60 number.
func (Port) MarshalYAML ¶
MarshalYAML emits the mapping as a double-quoted YAML scalar.
type Service ¶
type Service struct {
Build *Build `yaml:"build,omitempty"`
Image string `yaml:"image,omitempty"`
EnvFile []EnvFileEntry `yaml:"env_file,omitempty"`
Volumes []string `yaml:"volumes,omitempty"`
Ports []Port `yaml:"ports,omitempty"`
Environment []string `yaml:"environment,omitempty"`
DependsOn DependsOn `yaml:"depends_on,omitempty"`
Healthcheck *Healthcheck `yaml:"healthcheck,omitempty"`
Extra map[string]any `yaml:",inline"`
}
Service is a single container definition listed under `services:`.
Extra is an inline catch-all for service keys this model does not type (`image`, `command`, `restart`, `healthcheck`, ...), preserved verbatim across a regeneration.
type Volume ¶
type Volume struct {
Driver string `yaml:"driver,omitempty"`
Name string `yaml:"name,omitempty"`
External bool `yaml:"external,omitempty"`
Extra map[string]any `yaml:",inline"`
}
Volume is a named entry under the top-level `volumes:` key. A nil *Volume denotes a default volume and marshals to a null node — e.g. `go-module-cache:` — telling Compose to use default driver settings.
Extra preserves volume keys this model does not type (`driver_opts`, `labels`, ...).