Documentation
¶
Index ¶
- func ApplyExtraPorts(content string, extraPorts []string) string
- func BindForLAN(content string, lanExposed bool) string
- func BuildFPMImage(version string, local bool) error
- func BuildFPMImageTo(version string, local bool, w io.Writer) error
- func BundledExtensions() []string
- func ContainerExists(name string) (bool, error)
- func ContainerRunning(name string) (bool, error)
- func ContainerfileHash() (string, error)
- func DaemonReload() error
- func EnsureNetwork(name string) error
- func EnsureNetworkDNS(name string, servers []string) error
- func EnsurePathMounted(path, phpVersion string)
- func EnsureUserIni(version string) error
- func ExtraVolumePaths() []string
- func GenerateCustomQuadlet(svc *config.CustomService) string
- func GetQuadletTemplate(name string) (string, error)
- func ImageExists(image string) bool
- func InjectExtraVolumes(content string, paths []string) string
- func NeedsFPMRebuild() bool
- func NetworkGateway(name string) string
- func OCIRuntime() string
- func PullImageTo(image string, w io.Writer) error
- func QuadletInstalled(name string) bool
- func RebuildFPMImage(version string, local bool) error
- func RebuildFPMImageTo(version string, local bool, w io.Writer) error
- func RemoveContainer(name string)
- func RemoveQuadlet(name string) error
- func RestartUnit(name string) error
- func RewriteFPMQuadlets() error
- func Run(args ...string) (string, error)
- func RunSilent(args ...string) error
- func ServiceImage(quadletName string) string
- func ServiceVersion(quadletName string) string
- func StartUnit(name string) error
- func StopUnit(name string) error
- func StoreFPMHash() error
- func StripInstallSection(content string, autostartDisabled bool) string
- func UnitStatus(name string) (string, error)
- func WaitReady(service string, timeout time.Duration) error
- func WriteContainerHosts() error
- func WriteFPMQuadlet(version string) error
- func WriteQuadlet(name, content string) error
- func WriteQuadletDiff(name, content string) (changed bool, err error)
- func WriteXdebugIni(version string, enabled bool) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyExtraPorts ¶ added in v1.0.0
ApplyExtraPorts appends extra PublishPort lines to quadlet content.
func BindForLAN ¶ added in v1.8.0
BindForLAN rewrites every PublishPort= line in a quadlet so the host-side bind matches the requested LAN-exposure state. The embedded quadlet files use the unprefixed `PublishPort=80:80` form, which podman interprets as binding 0.0.0.0 (all interfaces). When lanExposed is false (the default safe-on-coffee-shop-wifi state) we rewrite each unprefixed line to `PublishPort=127.0.0.1:80:80` so only the local host can connect; when true, we leave the unprefixed form alone so LAN clients can reach the service.
Lines that already have an explicit IP prefix (lerd-dns binds 127.0.0.1 directly because the LAN path goes through the userspace forwarder, not the publish) are left untouched in both states.
func BuildFPMImage ¶ added in v0.1.14
BuildFPMImage builds the lerd PHP-FPM image for the given version if it doesn't exist. When local is false, it attempts to pull a pre-built base image from ghcr.io first.
func BuildFPMImageTo ¶ added in v0.5.6
BuildFPMImageTo builds the PHP-FPM image writing output to w. When local is false, it attempts to pull a pre-built base image from ghcr.io first.
func BundledExtensions ¶ added in v0.5.5
func BundledExtensions() []string
BundledExtensions returns the set of PHP extensions included in the default lerd FPM image.
func ContainerExists ¶
ContainerExists returns true if the named container exists (running or not).
func ContainerRunning ¶
ContainerRunning returns true if the named container is running.
func ContainerfileHash ¶ added in v0.1.25
ContainerfileHash returns the SHA-256 hash of the embedded PHP-FPM Containerfile. This is used to detect when images need to be rebuilt after a lerd update.
func EnsureNetwork ¶
EnsureNetwork creates the named Podman network if it does not already exist.
func EnsureNetworkDNS ¶ added in v1.0.3
EnsureNetworkDNS syncs the DNS servers on the named network to the provided list. It drops servers no longer present and adds new ones. This sets the upstream forwarders that aardvark-dns uses, which is necessary on systems where /etc/resolv.conf points to a stub resolver (e.g. 127.0.0.53) that is not reachable from inside the container network namespace.
func EnsurePathMounted ¶ added in v1.9.3
func EnsurePathMounted(path, phpVersion string)
EnsurePathMounted checks whether the given path is accessible inside the PHP-FPM and nginx containers. If the path is outside $HOME and not already volume-mounted, the quadlets are updated and containers restarted transparently before returning.
func EnsureUserIni ¶ added in v0.5.5
EnsureUserIni creates the per-version user php.ini with defaults if it doesn't exist.
func ExtraVolumePaths ¶ added in v1.9.3
func ExtraVolumePaths() []string
ExtraVolumePaths returns absolute paths that need to be bind-mounted into the PHP-FPM container because they are outside the user's home directory. It collects parked directories and linked site paths, deduplicates them, and returns only the top-level ancestors (so /var/www covers /var/www/app).
func GenerateCustomQuadlet ¶ added in v0.5.4
func GenerateCustomQuadlet(svc *config.CustomService) string
GenerateCustomQuadlet builds a quadlet .container file for a custom service.
func GetQuadletTemplate ¶
GetQuadletTemplate returns the content of a named quadlet template file.
func ImageExists ¶ added in v0.5.6
ImageExists returns true if the named image is present in the local store.
func InjectExtraVolumes ¶ added in v1.9.3
InjectExtraVolumes adds Volume= lines for paths that are not already covered by the %h:%h mount. Each path is bind-mounted read-write at the same location inside the container. Existing Volume= lines for the same host path are not duplicated.
func NeedsFPMRebuild ¶ added in v0.1.25
func NeedsFPMRebuild() bool
NeedsFPMRebuild returns true if the stored Containerfile hash differs from the current embedded Containerfile, meaning images should be rebuilt.
func NetworkGateway ¶ added in v0.1.14
NetworkGateway returns the gateway IP of the named Podman network. Falls back to "127.0.0.1" if it cannot be determined.
func OCIRuntime ¶ added in v1.9.3
func OCIRuntime() string
OCIRuntime returns the name of the OCI runtime podman is currently configured to use.
func PullImageTo ¶ added in v0.5.6
PullImageTo pulls the named image, writing progress output to w.
func QuadletInstalled ¶ added in v0.1.17
QuadletInstalled returns true if a quadlet .container file exists for the given unit name.
func RebuildFPMImage ¶ added in v0.1.17
RebuildFPMImage force-removes and rebuilds the PHP-FPM image for the given version. When local is false, it attempts to pull a pre-built base image from ghcr.io first.
func RebuildFPMImageTo ¶ added in v0.5.6
RebuildFPMImageTo force-rebuilds the PHP-FPM image writing output to w. When local is false, it attempts to pull a pre-built base image from ghcr.io first.
func RemoveContainer ¶ added in v1.5.0
func RemoveContainer(name string)
RemoveContainer removes a stopped Podman container by name, ignoring errors if the container does not exist.
func RemoveQuadlet ¶
RemoveQuadlet removes a Podman quadlet container unit file.
func RewriteFPMQuadlets ¶ added in v1.9.3
func RewriteFPMQuadlets() error
RewriteFPMQuadlets regenerates the quadlet files for all installed PHP-FPM versions and the nginx quadlet. Call this when parked directories or site paths change so that extra volume mounts stay in sync.
func ServiceImage ¶ added in v0.5.6
ServiceImage returns the OCI image name embedded in a named quadlet template. Returns "" if the quadlet or Image line is not found.
func ServiceVersion ¶ added in v1.6.0
ServiceVersion extracts the major version from a built-in service's image tag. For example: mysql:8.0 → "8.0", postgis/postgis:16-3.5-alpine → "16", redis:7-alpine → "7", meilisearch:v1.7 → "1.7". Returns "" if the version cannot be determined.
func StoreFPMHash ¶ added in v0.1.25
func StoreFPMHash() error
StoreFPMHash writes the current Containerfile hash to disk.
func StripInstallSection ¶ added in v1.9.0
StripInstallSection removes the [Install] section from a quadlet's content when autostartDisabled is true, and returns the input unchanged when false.
Quadlets are special: a `[Install] WantedBy=default.target` clause causes the podman-system-generator to create a symlink in `/run/user/$UID/systemd/generator/default.target.wants/` on every daemon-reload, which makes the unit auto-start at login regardless of `systemctl --user enable/disable` (those don't apply to generator units). The only way to actually stop a quadlet from auto-starting is to drop the [Install] section from the source .container file before the generator sees it. WriteQuadletDiff calls this centrally so every code path that writes a quadlet (install, services, MCP server, custom-service generator) honours the global autostart setting without each having to remember.
func UnitStatus ¶
UnitStatus returns the active state of a systemd user unit.
func WaitReady ¶ added in v1.2.2
WaitReady polls until the named service is ready to accept connections, or timeout is reached. Readiness is tested by running a lightweight probe inside the container: mysqladmin ping for mysql, pg_isready for postgres. For other services it falls back to waiting until the systemd unit is "active".
func WriteContainerHosts ¶ added in v1.2.4
func WriteContainerHosts() error
WriteContainerHosts writes the shared hosts file that is bind-mounted into every PHP-FPM container at /etc/hosts. It contains the standard loopback entries, host.containers.internal, and one entry per linked site pointing to host.containers.internal (169.254.1.2) so that .test domains resolve correctly inside containers without requiring a container restart when sites are added or removed.
func WriteFPMQuadlet ¶ added in v0.4.0
WriteFPMQuadlet writes the systemd quadlet for a PHP-FPM version and reloads the systemd daemon if the content changed. It also ensures the xdebug and user ini files exist.
func WriteQuadlet ¶
WriteQuadlet writes a Podman quadlet container unit file. Before writing it applies BindForLAN to rewrite PublishPort= lines according to the current cfg.LAN.Exposed setting. This is done centrally here so callers (install, services, MCP server, custom-service generator) all get the same loopback-by-default treatment without each having to remember.
func WriteQuadletDiff ¶ added in v1.8.0
WriteQuadletDiff writes a quadlet like WriteQuadlet, but also reports whether the on-disk file actually changed. Callers can use this to daemon-reload + restart only the units that need it (e.g. lerd install rewriting binds from 0.0.0.0 to 127.0.0.1 when migrating to a build where lan:expose defaults to off — without a restart the running container would silently keep its old bind).
func WriteXdebugIni ¶ added in v0.4.0
WriteXdebugIni writes the per-version xdebug ini to the host config dir. The file is volume-mounted into the FPM container at /usr/local/etc/php/conf.d/99-xdebug.ini.
Types ¶
This section is empty.