Documentation
¶
Index ¶
- Constants
- Variables
- func ProfilerIsPaid(profiler string) bool
- func SettingsSchema() *jsonschema.Schema
- func ValidateSettings(s Settings) error
- type BackgroundProcess
- type DiscoveredService
- type Environment
- func (e *Environment) AdminWatchURL() string
- func (e *Environment) Discover(ctx context.Context) (RunningEnvironment, error)
- func (e *Environment) PortConflicts(ctx context.Context) []PortConflict
- func (e *Environment) ProxyHost() string
- func (e *Environment) RoutedSubdomains() []string
- func (e *Environment) StorefrontWatchURL() string
- func (e *Environment) WebImage() string
- func (e *Environment) WriteCompose() error
- type Link
- type Options
- type PHP
- type Port
- type PortConflict
- type PortOverride
- type Ports
- type Proxy
- type RunningEnvironment
- type ServiceSettings
- type Settings
Constants ¶
const ( ServiceWeb = "web" ServiceDatabase = "database" ServiceAdminer = "adminer" ServiceMailer = "mailer" ServiceWorker = "worker" ServiceScheduler = "scheduler" ServiceQueue = "queue" ServiceSearch = "search" ServiceCache = "cache" ServiceStorage = "storage" ServiceStorageInit = "storage-init" ServiceBlackfire = "blackfire" ServiceTideways = "tideways-daemon" )
Compose service names.
const ( PortHTTP = "http" PortHTTPAlt = "http_alt" PortAdminWatcher = "admin_watcher" PortAdminWatcherHMR = "admin_watcher_hmr" PortStorefrontWatcher = "storefront_watcher" PortStorefrontWatcherAssets = "storefront_watcher_assets" PortMySQL = "mysql" PortSMTP = "smtp" PortAMQP = "amqp" PortManagement = "management" PortS3 = "s3" PortConsole = "console" )
Endpoint names, the keys under docker.services.<service>.ports.
const ( DatabaseMariaDB = "mariadb" DatabaseMySQL = "mysql" QueueLavinMQ = "lavinmq" QueueRabbitMQ = "rabbitmq" )
Variant names, the values of docker.services.<service>.type.
const ( ProfilerBlackfire = "blackfire" ProfilerTideways = "tideways" ProfilerXdebug = "xdebug" ProfilerPcov = "pcov" ProfilerSpx = "spx" )
Profiler names for the PHP profiler setting.
const EnvLocalContent = "APP_ENV=dev\n"
EnvLocalContent is the initial .env.local of a Docker project. It is written when the file is missing so compose can start, and by the project scaffold.
Variables ¶
var DefaultShopURL = loopbackURL(mustEndpoint(ServiceWeb, PortHTTP).DefaultHostPort)
DefaultShopURL is the shop URL with default ports and no proxy.
var Profilers = []string{"", ProfilerXdebug, ProfilerBlackfire, ProfilerTideways, ProfilerPcov, ProfilerSpx}
Profilers is the ordered list of profiler names. The empty string means "no profiler".
Functions ¶
func ProfilerIsPaid ¶
ProfilerIsPaid reports whether the given profiler is a commercial product that requires a paid account or plan. Blackfire and Tideways are paid SaaS products; xdebug, pcov and spx are free and open source.
func SettingsSchema ¶
func SettingsSchema() *jsonschema.Schema
SettingsSchema returns the JSON schema of docker.services: one object per configurable catalog service, each allowing only the keys that apply to it. Port values reference the "Port" definition the config schema declares.
func ValidateSettings ¶
ValidateSettings rejects services, endpoints and types the catalog does not know, so a typo in docker.services fails at config read time instead of being silently ignored.
Types ¶
type BackgroundProcess ¶
BackgroundProcess is a long-running compose service without a published port (the messenger worker and scheduled-task runner). Running reflects whether its container is currently up.
type DiscoveredService ¶
DiscoveredService is an auxiliary service of the running development environment with the URL and credentials it is reached with from the host.
type Environment ¶
type Environment struct {
// contains filtered or unexported fields
}
Environment is a project's Docker dev environment: everything needed to generate its compose file, probe its host ports, resolve its URLs and inspect its containers. It is a snapshot of the project (composer.lock, Symfony configuration) and the options it was built with; rebuild it after the configuration changes.
func NewEnvironment ¶
func NewEnvironment(projectRoot string, opts Options) (*Environment, error)
NewEnvironment resolves the dev environment of the project at projectRoot: it reads composer.lock for the optional services, the Symfony configuration for the admin worker toggle, and the project folder's owner as the container user unless opts.User is set. A project without a readable composer.lock has no environment.
func (*Environment) AdminWatchURL ¶
func (e *Environment) AdminWatchURL() string
AdminWatchURL returns where the administration watcher is reachable from the host: its proxy subdomain when the project is proxied, otherwise its published port honoring docker.services.web.ports. It returns "" when the port is disabled.
func (*Environment) Discover ¶
func (e *Environment) Discover(ctx context.Context) (RunningEnvironment, error)
Discover inspects the project's containers via `docker compose ps` and classifies them into published auxiliary services, background processes, and the shop's published web port. Proxied services publish no host port and are reached at their subdomain instead.
func (*Environment) PortConflicts ¶
func (e *Environment) PortConflicts(ctx context.Context) []PortConflict
PortConflicts probes the fixed host ports the compose file will publish and returns those already bound by something other than this project's own containers. Routed services publish nothing in proxy mode and are skipped; probe failures count as "free" so `docker compose up` surfaces real errors itself.
func (*Environment) ProxyHost ¶
func (e *Environment) ProxyHost() string
ProxyHost returns the project's proxy hostname, or "" in fixed-port mode.
func (*Environment) RoutedSubdomains ¶
func (e *Environment) RoutedSubdomains() []string
RoutedSubdomains returns every proxy subdomain the environment's services are routed at, in catalog order. The web service contributes the root hostname ("") plus the watcher subdomains. It is independent of the run mode so the browser-facing hostnames can be listed before the proxy is up.
func (*Environment) StorefrontWatchURL ¶
func (e *Environment) StorefrontWatchURL() string
StorefrontWatchURL returns where the storefront watcher is reachable from the host, resolved like AdminWatchURL.
func (*Environment) WebImage ¶
func (e *Environment) WebImage() string
WebImage returns the docker-dev image the web and console services run.
func (*Environment) WriteCompose ¶
func (e *Environment) WriteCompose() error
WriteCompose renders compose.yaml into the project folder and creates .env.local when it is missing.
type Link ¶
Link is a labelled URL of a service's user interface.
func ServiceLink ¶
ServiceLink returns the label and proxy URL of a compose service's user interface, for listing a proxied project's services. It reports false for unknown, hidden and unrouted services.
type Options ¶
type Options struct {
// PHP configures the docker-dev image and its profiler.
PHP PHP
// Services are the per-service settings from docker.services.
Services Settings
// Proxy, when set, serves the project through the shared proxy: routed
// services publish no host ports and instead join the proxy network with
// Traefik routing labels. Nil keeps fixed-port mode.
Proxy *Proxy
// User is the "uid:gid" the PHP containers run as so that writes to the
// bind-mounted project are owned by the host user. Empty resolves the
// host user of the project folder.
User string
}
Options are the caller-provided inputs of a dev environment: how PHP is set up, what the user configured per service, and whether the project is served through the shared proxy.
type PHP ¶
type PHP struct {
// Version is the PHP version (e.g. "8.3"); empty means the default.
Version string
// Profiler is one of the Profiler* names; empty means none.
Profiler string
BlackfireServerID string
BlackfireServerToken string
TidewaysAPIKey string
}
PHP configures the docker-dev image the PHP containers run.
type Port ¶
type Port int
Port is a host-port override. Its YAML value is either a port number or false to not publish the port at all.
const PortDisabled Port = -1
PortDisabled marks a port that is not published to the host (the YAML value false).
func (Port) JSONSchema ¶
func (Port) JSONSchema() *jsonschema.Schema
func (Port) MarshalYAML ¶
type PortConflict ¶
type PortConflict struct {
// Service is the compose service publishing the port.
Service string
// Endpoint is the ports key of the busy endpoint.
Endpoint string
// Label is the human-readable name of the endpoint.
Label string
// HostPort is the effective (configured or default) port that is busy.
HostPort int
}
PortConflict reports a host port that is already bound by another process.
func (PortConflict) ConfigPath ¶
func (c PortConflict) ConfigPath() string
ConfigPath is the docker.services path of the conflicting port, for messages that tell the user what to edit.
type PortOverride ¶
PortOverride pins one service endpoint to a host port.
func AllocateRandomPorts ¶
func AllocateRandomPorts(ctx context.Context, conflicts []PortConflict) ([]PortOverride, error)
AllocateRandomPorts picks a distinct free host port for every conflict and returns one override per conflict, in conflict order. All listeners stay open until every port is chosen so no port is handed out twice.
type Ports ¶
Ports maps a service's endpoint name to the host port it binds, or to PortDisabled to not publish the endpoint at all.
type Proxy ¶
type Proxy struct {
// Hostname is the project's resolved root hostname, e.g.
// "my-shop.shopware.local". Every other route is a subdomain of it (e.g.
// "admin-watch.my-shop.shopware.local").
Hostname string
// NetworkName is the external Docker network shared with Traefik.
NetworkName string
// CABundlePath is the host path of a CA bundle that combines the image's
// system CAs with the proxy's root CA. When set, it is mounted read-only
// over the container's system trust store so everything there — PHP, curl
// (e.g. Shopware's own APP_URL reachability self-call) and Node — trusts the
// proxy's HTTPS certificates while still trusting the public internet.
// Mounting the bare CA under /usr/local/share/ca-certificates is not enough:
// the image runs as www-data and never runs update-ca-certificates.
CABundlePath string
// AdminWatchPort is the container port the admin watcher's dev server binds:
// Vite (5173) on Shopware 6.7+, webpack-dev-server (8080) before, decided by
// the ADMIN_VITE feature flag. The caller computes it (via
// extension.AdminDevServerPort) and passes it in, so this package needs no
// Shopware-version logic of its own.
AdminWatchPort int
}
Proxy carries the data needed to route a project's services through the shared shopware-cli proxy by hostname instead of fixed host ports.
type RunningEnvironment ¶
type RunningEnvironment struct {
// Services are the auxiliary services reachable from the host.
Services []DiscoveredService
// Background are the long-running console processes.
Background []BackgroundProcess
// WebPort is the host port the shop is published on, 0 when it cannot be
// determined (environment down, web container not publishing).
WebPort int
}
RunningEnvironment is the running development environment's containers, classified by role.
type ServiceSettings ¶
type ServiceSettings struct {
// Implementation to run, for services that offer more than one (database: mariadb or mysql, queue: lavinmq or rabbitmq).
Type string `yaml:"type,omitempty"`
// Image version (tag) to run. Defaults per implementation.
Version string `yaml:"version,omitempty"`
// Host ports the service's endpoints are published on, keyed by endpoint name. false disables publishing an endpoint.
Ports Ports `yaml:"ports,omitempty"`
}
ServiceSettings configures one compose service of the dev environment. It is the YAML shape of docker.services.<service>.