builds

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: Apache-2.0 Imports: 25 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 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

View Source
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 Repository

func Repository(sv store.Service) string

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 New

func New(st *store.Store, box *secrets.Box, jm *jobs.Manager, wl *workload.Manager, issuer *registry.Issuer, bus *events.Bus, log *slog.Logger, cfg Config) *Manager

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; "" means the source's branch) or the given sha. Path filters do not apply.

func (*Manager) Check

func (m *Manager) Check(sourceID string)

Check asks for an immediate poll of a source after a push webhook.

func (*Manager) CheckRepo

func (m *Manager) CheckRepo(ctx context.Context, connectionID, repo string) int

CheckRepo polls every source building a connection's repository (a GitHub App push webhook).

func (*Manager) DeleteSource

func (m *Manager) DeleteSource(ctx context.Context, serviceID string) error

DeleteSource disconnects a service from Git and removes the webhook SynCloud created.

func (*Manager) Deploy

func (m *Manager) Deploy(ctx context.Context, b store.Build) error

Deploy rolls out a successful build's image as a new revision.

func (*Manager) GetSettings

func (m *Manager) GetSettings(ctx context.Context, sv store.Service) (Settings, error)

GetSettings returns a service's build settings.

func (*Manager) GetSource

func (m *Manager) GetSource(ctx context.Context, serviceID string) (Source, error)

func (*Manager) ListSources

func (m *Manager) ListSources(ctx context.Context) ([]SourceSummary, error)

ListSources returns every Git source with its service.

func (*Manager) Run

func (m *Manager) Run(ctx context.Context)

Run polls sources and starts queued builds until ctx ends.

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.

func (*Manager) SetSource

func (m *Manager) SetSource(ctx context.Context, sv store.Service, in Source) (Source, error)

SetSource connects a service to a repository.

func (*Manager) WebhookSecret

func (m *Manager) WebhookSecret(ctx context.Context, sourceID string) (string, error)

WebhookSecret returns a source's secret for signature checks.

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.

type SourceSummary

type SourceSummary struct {
	Source
	Project     string `json:"project"`
	Environment string `json:"environment"`
	Service     string `json:"service"`
}

SourceSummary is a Git source with the service it builds.

Jump to

Keyboard shortcuts

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