services

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2026 License: MIT Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package services generates configuration for the v5 control-plane daemons installed by `coolify init` (corrosion + coold). All functions are pure: they emit bytes/strings and do no I/O.

Index

Constants

View Source
const BuilderBinaryPath = "/usr/local/bin/builder"

BuilderBinaryPath is the path to the builder binary coold spawns as a short-lived subprocess under a `systemd-run --scope` transient unit. No long-running builder daemon exists on the host.

View Source
const BuilderWorkDir = "/var/lib/coolify-builder/work"

BuilderWorkDir is the scratch root coold creates per-build subdirectories in when it dispatches a `BuildRequest`. Cleaned per-request by coold.

View Source
const CooldAPIPort = 8443

CooldAPIPort is the TCP port coold's firewall REST API binds on wg0.

View Source
const CooldAPITokenPath = "/etc/coolify/api-token" //nolint:gosec // filesystem path, not a credential

CooldAPITokenPath is the on-host path where coold reads the bearer token for the firewall REST API. The file is generated once by `coolify init apply --install-coold` (random 32-byte hex via `openssl rand`) and kept mode 0600.

View Source
const CoolifySchemaSQL = `` /* 424-byte string literal not displayed */

CoolifySchemaSQL is the Corrosion schema that coold's sync loop writes to.

Every NOT NULL column MUST have a DEFAULT — corrosion's CR-SQLite backend rejects schemas missing defaults with "needs a default value for forward schema compatibility". Defaults are never surfaced at runtime because coold always provides every column on upsert.

Columns:

  • container_name: globally unique DNS label. coold's embedded resolver answers <container_name>.coolify.internal → container_ip. Uniqueness is Coolify's responsibility at app-create time.
  • namespace: optional app-scoping key reserved for multi-tenant / per-app isolation (e.g. one podman network per namespace). Empty string in single-tenant deployments. Opaque DNS-safe string owned by Coolify.
  • state: raw podman container status (running, exited, stopped, restarting, paused, created, dead, configured, removing). Liveness.
  • health: podman HEALTHCHECK result. One of: "healthy", "unhealthy", "starting", "unknown". "unknown" when the container has no HEALTHCHECK declared. Readiness.
View Source
const DefaultCooldDNSZone = "coolify.internal"

DefaultCooldDNSZone is the DNS zone served by coold's embedded resolver. `.internal` is RFC 6761 reserved — safe from public-TLD collisions.

View Source
const HostJWTPath = "/etc/coolify/host-jwt"

HostJWTPath is the on-host path where coold reads its bearer JWT.

View Source
const SchedulerGRPCPort = 6443

SchedulerGRPCPort is the TCP port scheduler listens on. coold dials this stream and carries both coold and builder traffic on the same connection — there is no longer a separate listener for builds.

View Source
const SchedulerJWTPrivPath = "/etc/coolify/jwt.priv"

SchedulerJWTPrivPath is the on-central path for the EC private key (chmod 0600).

View Source
const SchedulerJWTPubPath = "/etc/coolify/jwt.pub"

SchedulerJWTPubPath is the on-host path where the scheduler reads the ES256 public key.

View Source
const SchedulerUnixSocketPath = "/run/coolify/scheduler.sock"

SchedulerUnixSocketPath is the on-host path of the scheduler's HTTP-over-UDS listener. The central-plane caller (Laravel) connects here. Access control is filesystem perms — see SchedulerServiceUnit.

Variables

This section is empty.

Functions

func BuilderInstallCommand

func BuilderInstallCommand(version string) string

BuilderInstallCommand returns a shell snippet that installs buildah + git (required by the builder pipeline), ensures the work directory exists, and downloads the builder binary from the GitHub release for the given version tag. The version tag should track the coold release — builder and coold ship from the same workspace.

func CooldInstallCommand

func CooldInstallCommand(version string) string

CooldInstallCommand returns a shell snippet that downloads and installs coold from the GitHub release for the given version tag (e.g. "nightly", "v1.2.3"). Architecture is auto-detected on the remote host via uname -m. The version tag is written to /usr/local/bin/coold.version after install.

func CooldNamespacesEnvValue

func CooldNamespacesEnvValue(ns []CooldNamespace) string

CooldNamespacesEnvValue renders the COOLD_NAMESPACES env value. Shape:

default:coolify-default-mesh:10.210.0.1,alpha:coolify-alpha-mesh:10.220.0.1

Triples are comma-separated; fields within a triple are colon-separated. Empty slice yields empty string so callers can omit the env var entirely.

func CooldServiceUnit

func CooldServiceUnit(mgmtIP net.IP, namespaces []CooldNamespace) string

CooldServiceUnit renders the coold systemd unit without scheduler or builder env (phase-3 first install, before phase 5 rewrites the unit to inject scheduler settings).

func CooldServiceUnitWithScheduler

func CooldServiceUnitWithScheduler(mgmtIP net.IP, namespaces []CooldNamespace, scheduler *SchedulerConfig, builder *BuilderConfig) string

CooldServiceUnitWithScheduler is like CooldServiceUnit but injects scheduler env vars when scheduler is non-nil and builder env vars when builder is non-nil. Used for non-central hosts after phase 4.

func CorrosionConfigBytes

func CorrosionConfigBytes(bindAddr net.IP, gossipPort, apiPort int, peers []net.IP) []byte

CorrosionConfigBytes renders /etc/corrosion/config.toml for a single host.

bindAddr is this host's wg0 management IP — gossip is confined to the mesh (already encrypted by WireGuard, so plaintext=true is safe). peers are the mgmt IPs of all OTHER hosts; they are sorted lexically so the output is byte-stable across probe orderings (needed for sha256 drift check).

func CorrosionInstallCommand

func CorrosionInstallCommand(version string) string

CorrosionInstallCommand returns a shell snippet that downloads and installs corrosion from the GitHub release for the given version tag. Architecture is auto-detected on the remote host via uname -m. The version tag is written to /usr/local/bin/corrosion.version after install.

func CorrosionServiceUnit

func CorrosionServiceUnit(iface string) string

CorrosionServiceUnit returns the systemd unit text for corrosion. Plain .service (not a template unit); iface is baked into the dependency.

func EnsureCooldAPITokenCommand

func EnsureCooldAPITokenCommand() string

EnsureCooldAPITokenCommand returns a shell snippet that creates the CooldAPITokenPath file with a random 32-byte hex token if it does not already exist. Idempotent: repeated runs preserve the existing token so clients already trusting it keep working.

func EnsureJWTKeypairCommand

func EnsureJWTKeypairCommand() string

EnsureJWTKeypairCommand returns a shell snippet that generates an EC P-256 keypair in PKCS8 format on the central host (idempotent).

func MintHostJWT

func MintHostJWT(privKeyPEM []byte, hostID string, caps []string) (string, error)

MintHostJWT creates a 1-year ES256 JWT signed with the EC P-256 private key.

privKeyPEM must be PKCS8 EC PEM (produced by `openssl genpkey -algorithm EC -pkeyopt ec_paramgen_curve:P-256`). hostID becomes the `sub` claim; the scheduler uses it as the key into its host→stream registry.

caps lists the capabilities this host is authorized to advertise in the coold Hello frame. Always includes "coold"; hosts that accept builds also carry "builder". The scheduler cross-checks the advertised Hello capability set against this claim and rejects streams that try to elevate.

func SchedulerInstallCommand

func SchedulerInstallCommand(version string) string

SchedulerInstallCommand returns a shell snippet that downloads and installs scheduler from the GitHub release for the given version tag.

func SchedulerServiceUnit

func SchedulerServiceUnit(grpcBind, jwtPubPath string) string

SchedulerServiceUnit returns the systemd unit text for scheduler.

grpcBind is "ip:port" for the single gRPC listener (e.g. "100.64.0.1:6443"). It binds on the central host's wg0 mgmt IP so the listener is unreachable outside the mesh.

RuntimeDirectory=coolify creates /run/coolify owned by the scheduler user at unit start, which is where the UDS gets bound. Laravel group access is configured at deploy time via SCHEDULER_UNIX_SOCKET_GROUP once the PHP-FPM group is finalized; until then the socket stays 0600.

Types

type BuilderConfig

type BuilderConfig struct {
	Capacity    int      // concurrent builds the host accepts; 0 falls back to 2
	CPUQuota    string   // systemd CPUQuota per build scope; "" falls back to "200%"
	MemoryMax   string   // systemd MemoryMax per build scope; "" falls back to "2G"
	TimeoutSecs int      // hard per-build timeout in seconds; 0 falls back to 1800
	DenyNets    []string // extra CIDRs to deny at systemd-run IPAddressDeny level
}

BuilderConfig carries the builder-capability env vars coold needs when it spawns build subprocesses. nil means the capability is disabled and no COOLD_BUILDER_* env vars are emitted.

type CooldNamespace

type CooldNamespace struct {
	Name          string // e.g. "default", "alpha"
	Network       string // e.g. "coolify-default-mesh" — podman bridge name
	BridgeGateway net.IP // the .1 of that namespace's per-host container subnet
}

CooldNamespace describes one namespace for coold's env var. coold's embedded DNS binds <BridgeGateway>:53 per namespace, and its sync loop iterates `Network` to discover containers.

type SchedulerConfig

type SchedulerConfig struct {
	URL     string // e.g. "http://100.64.0.1:6443"
	JWTPath string // e.g. "/etc/coolify/host-jwt"
}

SchedulerConfig carries optional scheduler connectivity injected into the coold unit for non-central hosts. nil means no scheduler env vars are emitted.

Jump to

Keyboard shortcuts

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