Documentation
¶
Overview ¶
Package builds turns Git commits into images and deployments (§5.8): it polls Git sources (and reacts to webhooks), builds each new commit once with BuildKit as a privileged job run, pushes the image to the private registry and, with auto-deploy, rolls it out as a new revision.
Index ¶
- Constants
- func RefTag(ref string) string
- func Repository(sv store.Service) string
- type Config
- type Connections
- type ErrInvalid
- type Manager
- func (m *Manager) BuildNow(ctx context.Context, sv store.Service, ref, sha string) (store.Build, error)
- func (m *Manager) Check(sourceID string)
- func (m *Manager) CheckRepo(ctx context.Context, connectionID, repo string) int
- func (m *Manager) DeleteSource(ctx context.Context, serviceID string) error
- func (m *Manager) Deploy(ctx context.Context, b store.Build) error
- func (m *Manager) GetSettings(ctx context.Context, sv store.Service) (Settings, error)
- func (m *Manager) GetSource(ctx context.Context, serviceID string) (Source, error)
- func (m *Manager) ListSources(ctx context.Context) ([]SourceSummary, error)
- func (m *Manager) Run(ctx context.Context)
- func (m *Manager) SetSettings(ctx context.Context, sv store.Service, in SettingsInput) (Settings, error)
- func (m *Manager) SetSource(ctx context.Context, sv store.Service, in Source) (Source, error)
- func (m *Manager) WebhookSecret(ctx context.Context, sourceID string) (string, error)
- type Settings
- type SettingsInput
- type Source
- type SourceSummary
Constants ¶
const ( // BuildKitImage is pinned per release (§5.0 release manifest). BuildKitImage = "moby/buildkit:v0.25.1" // StaticImage serves static sites (index.html, no Dockerfile). StaticImage = "nginx:1.29-alpine" // Nixpacks builds apps without a Dockerfile; the download is checked // against these digests. NixpacksVersion = "1.41.0" // TopicBuild carries a store.Build whenever a build changes. TopicBuild = "build.updated" BuildQueued = "queued" BuildBuilding = "building" BuildSucceeded = "succeeded" BuildFailed = "failed" // BuildChecking: built, and the after-build checks run in the image. BuildChecking = "checking" // BuildSkipped means no changed file matched the path filters. BuildSkipped = "skipped" )
Variables ¶
This section is empty.
Functions ¶
func RefTag ¶ added in v0.3.1
RefTag is the tag a build of ref is also pushed under: the git tag's name, or latest-<branch>. Images keep only their commit id once a newer build moves it, so lifecycle rules map ids back to it.
func Repository ¶
Repository is the registry path for a service's images.
Types ¶
type Config ¶
type Config struct {
// RegistryHost is where builds push ("" = the registry host of the base domain).
RegistryHost func() string
// RegistryInsecure pushes over plain HTTP (development).
RegistryInsecure bool
// Node pins builds to one node ("" = any schedulable node).
Node string
// UpstreamAuths are docker config.json "auths" for third-party
// registries (private FROM images); may be nil.
UpstreamAuths func() map[string]any
// SelfSignedCA returns the certificate of a platform host (the
// registry, the built-in Git server) while it is self-signed, else "".
SelfSignedCA func(host string) string
}
type Connections ¶
type Connections interface {
Provider(ctx context.Context, idOrName string) (store.GitConnection, gitprovider.Provider, error)
}
Connections resolves Git provider connections (§5.8).
type ErrInvalid ¶
type ErrInvalid struct{ Err error }
ErrInvalid wraps validation errors.
func (ErrInvalid) Error ¶
func (e ErrInvalid) Error() string
type Manager ¶
type Manager struct {
// Connections lets sources name a repository of a connected provider
// (nil: sources need a URL).
Connections Connections
// DashboardURL is where Git hosts send webhooks and commit statuses link.
DashboardURL func() string
// BuildSlots returns a service's project and its concurrent-builds
// quota (0: none).
BuildSlots func(ctx context.Context, serviceID string) (projectID string, limit int)
// contains filtered or unexported fields
}
func (*Manager) BuildNow ¶
func (m *Manager) BuildNow(ctx context.Context, sv store.Service, ref, sha string) (store.Build, error)
BuildNow queues a commit: the head of ref (a branch or tag name, or a full refs/heads/… or refs/tags/… ref; "" means the source's branch) or the given sha. Path filters do not apply, and a commit built before is built again (a rebuild picks up changed build settings and variables).
func (*Manager) Check ¶
Check asks for an immediate poll of a source after a push webhook, and of every other source building the same repository: in a monorepo one webhook serves all its services (path filters pick which ones build).
func (*Manager) CheckRepo ¶
CheckRepo polls every source building a connection's repository (a GitHub App push webhook).
func (*Manager) DeleteSource ¶
DeleteSource disconnects a service from Git and removes the webhook SynCloud created.
func (*Manager) Deploy ¶
Deploy rolls out a successful build's image as a new revision, also when that image is the one running (a redeploy: tasks restart and the tag is resolved again).
func (*Manager) GetSettings ¶
GetSettings returns a service's build settings.
func (*Manager) ListSources ¶
func (m *Manager) ListSources(ctx context.Context) ([]SourceSummary, error)
ListSources returns every Git source with its service.
func (*Manager) SetSettings ¶
func (m *Manager) SetSettings(ctx context.Context, sv store.Service, in SettingsInput) (Settings, error)
SetSettings validates and stores a service's build settings.
type Settings ¶
type Settings struct {
// InstallCommand, BuildCommand and StartCommand override what Nixpacks
// detects (NIXPACKS_INSTALL_CMD, …_BUILD_CMD, …_START_CMD).
InstallCommand string `json:"installCommand"`
BuildCommand string `json:"buildCommand"`
StartCommand string `json:"startCommand"`
// PostBuild commands run in order in the new image, with the service's
// variables, before it is deployed; a failure stops the deployment.
PostBuild []string `json:"postBuild"`
// Variables are build-time variables: Dockerfile build arguments and
// Nixpacks environment. Only their names are shown.
Variables []string `json:"variables"`
}
Settings are a Git source's build settings (Phase 15b): Nixpacks command overrides, build-time variables and after-build checks.
type SettingsInput ¶
type SettingsInput struct {
InstallCommand string `json:"installCommand"`
BuildCommand string `json:"buildCommand"`
StartCommand string `json:"startCommand"`
PostBuild []string `json:"postBuild"`
Variables map[string]*string `json:"variables"`
}
SettingsInput changes build settings. A variable set to null keeps its stored value; variables left out are removed.
type Source ¶
type Source struct {
URL string `json:"url"`
Branch string `json:"branch"`
Tags string `json:"tags"`
Paths []string `json:"paths"`
Builder string `json:"builder"`
Dockerfile string `json:"dockerfile"`
Context string `json:"context"`
Token string `json:"token,omitempty"` // write-only
HasToken bool `json:"hasToken"`
// Connection and Repo pick a repository of a connected provider instead
// of a URL; SynCloud then creates the webhook and reports statuses.
Connection string `json:"connection,omitempty"`
Repo string `json:"repo,omitempty"`
// Webhook is how pushes arrive: "created" (SynCloud added it to the
// repository), "app" (the GitHub App's) or "manual" (add it yourself).
Webhook string `json:"webhook"`
HookError string `json:"hookError,omitempty"`
AutoDeploy *bool `json:"autoDeploy,omitempty"`
PollSeconds int `json:"pollSeconds"`
WebhookPath string `json:"webhookPath"` // relative to the dashboard URL
Secret string `json:"webhookSecret"`
LastSHA string `json:"lastSha"`
LastChecked *time.Time `json:"lastCheckedAt"`
LastError string `json:"lastError"`
// Refs are the watched branches and tags with their last seen commit.
Refs map[string]string `json:"refs"`
LastWebhook *time.Time `json:"lastWebhookAt"`
}
Source is a Git source as the API shows and accepts it.