Documentation
¶
Overview ¶
Package serverless orchestrates serverless deployments across cloud providers.
Index ¶
- Constants
- Variables
- func BuildWorkerBundle(ctx context.Context, standaloneDir string, meta *nextcore.NextCorePayload, ...) (string, error)
- func CloudflareAssetBucketName(appName, environment string) string
- func CloudflareWorkerName(appName, environment string) string
- func Deploy(ctx context.Context, cfg *config.NextDeployConfig, ...) error
- func GenerateQuickReference(resMap ServerlessResourceMap) string
- func GenerateResourceView(appCfg *config.AppConfig, resMap ServerlessResourceMap) (string, error)
- func LoadLocalSecrets(cfg *config.NextDeployConfig) (map[string]string, error)
- func Rollback(ctx context.Context, cfg *config.NextDeployConfig, opts RollbackOptions) error
- type AWSProvider
- type CFTailEventDetail
- type CFTailException
- type CFTailLogEntry
- type CFTailMessage
- type CFTailRequest
- type CFTailResponse
- type CloudflareProvider
- type DeploymentEntry
- type ImageOptConfig
- type PlanAction
- type PlanItem
- type PlanResult
- type ProbeOutcome
- type Provider
- type ProviderRules
- type QueryOptions
- type RollbackOptions
- type ServerlessResourceMap
- type SmokeOpts
- type SmokeResult
- type TailOptions
- type UnmanagedResource
Constants ¶
const ( PlanCreate = cloudflare.PlanCreate PlanUpdate = cloudflare.PlanUpdate PlanNoOp = cloudflare.PlanNoOp PlanImmutableDrift = cloudflare.PlanImmutableDrift )
PlanAction constants.
Variables ¶
var DNSProviderRules = map[string]ProviderRules{ "namecheap": { Name: "Namecheap", Icon: "🧢", RootFormat: "@", WwwFormat: "www", SSLFormat: func(record dns.ValidationRecord) string { if strings.Contains(record.Name, ".www") { return record.Name } return strings.Split(record.Name, ".")[0] }, Warning: "⚠️ CRITICAL: NEVER include your domain name in the Host field! Use only the hash or '@'.", ProTip: "For www SSL records, the Host must include '.www' (e.g., '_5ab8c33b39a.www')", }, "cloudflare": { Name: "Cloudflare", Icon: "☁️", RootFormat: "@", WwwFormat: "www", SSLFormat: func(record dns.ValidationRecord) string { return strings.TrimSuffix(record.Name, ".") }, Warning: "⚠️ IMPORTANT: Set proxy status to DNS only (gray cloud) for SSL validation records!", ProTip: "After SSL is issued, you can enable the orange cloud (proxied) for better performance.", ProxyWarning: "🔴 SSL validation WILL FAIL if the cloud is orange! Keep it gray until certificate is issued.", }, "godaddy": { Name: "GoDaddy", Icon: "🇬", RootFormat: "@", WwwFormat: "www", SSLFormat: func(record dns.ValidationRecord) string { return strings.TrimSuffix(record.Name, ".") }, Warning: "⚠️ Do not include trailing dots in the 'Points to' field.", ProTip: "Use '@' for root domain, leave TTL as 1 hour.", }, "route53": { Name: "Route 53", Icon: "📡", RootFormat: "@", WwwFormat: "www", SSLFormat: func(record dns.ValidationRecord) string { return record.Name }, Warning: "✅ Use Alias records (A type) for better performance!", ProTip: "Route 53 handles validation automatically if domain is hosted here.", }, "other": { Name: "Other Provider", Icon: "🌐", RootFormat: "@", WwwFormat: "www", SSLFormat: func(record dns.ValidationRecord) string { return strings.TrimSuffix(record.Name, ".") }, Warning: "⚠️ Check your provider's documentation for exact field names.", ProTip: "Common field names: Host, Name, Alias, Points to.", }, }
DNSProviderRules maps provider names to their specific instructions.
Functions ¶
func BuildWorkerBundle ¶
func BuildWorkerBundle( ctx context.Context, standaloneDir string, meta *nextcore.NextCorePayload, cfg *config.NextDeployConfig, log *shared.Logger, ) (string, error)
BuildWorkerBundle adapts a Next.js standalone build into a single Cloudflare Worker module bundle.
func CloudflareAssetBucketName ¶ added in v0.16.0
CloudflareAssetBucketName computes the R2 asset bucket name for an app and environment.
func CloudflareWorkerName ¶ added in v0.16.0
CloudflareWorkerName computes the Worker script name for an app and environment.
func Deploy ¶
func Deploy(ctx context.Context, cfg *config.NextDeployConfig, meta *nextcore.NextCorePayload, verbose, provision, verify bool) error
Deploy orchestrates the full serverless deployment pipeline:
- Discovers the build artifact (app.tar.gz)
- Fetches local secrets via SecretManager and pushes them to the cloud secret store
- Uploads static assets to CDN/Storage
- Deploys the compute layer (Lambda, Workers, etc.)
- Invalidates the CDN cache
func GenerateQuickReference ¶
func GenerateQuickReference(resMap ServerlessResourceMap) string
GenerateQuickReference creates a markdown quick reference.
func GenerateResourceView ¶
func GenerateResourceView(appCfg *config.AppConfig, resMap ServerlessResourceMap) (string, error)
GenerateResourceView creates a premium HTML report of the provisioned resources.
func LoadLocalSecrets ¶
func LoadLocalSecrets(cfg *config.NextDeployConfig) (map[string]string, error)
LoadLocalSecrets is the exported alias for core.LoadLocalSecrets, used by CLI commands outside this package (e.g. `nextdeploy secrets prune`) that need to compute the canonical local secret set.
func Rollback ¶
func Rollback(ctx context.Context, cfg *config.NextDeployConfig, opts RollbackOptions) error
Rollback orchestrates the serverless rollback process. Opts forwards --steps / --to <commit> from the CLI down to the provider implementation.
Types ¶
type AWSProvider ¶
type AWSProvider = aws.AWSProvider
AWS provider types.
func NewAWSProvider ¶
func NewAWSProvider(verbose bool) *AWSProvider
NewAWSProvider creates a new AWS serverless provider.
type CFTailEventDetail ¶ added in v0.20.0
type CFTailEventDetail = cloudflare.CFTailEventDetail
Cloudflare provider & plan/tail types.
type CFTailException ¶ added in v0.20.0
type CFTailException = cloudflare.CFTailException
Cloudflare provider & plan/tail types.
type CFTailLogEntry ¶ added in v0.20.0
type CFTailLogEntry = cloudflare.CFTailLogEntry
Cloudflare provider & plan/tail types.
type CFTailMessage ¶ added in v0.20.0
type CFTailMessage = cloudflare.CFTailMessage
Cloudflare provider & plan/tail types.
type CFTailRequest ¶ added in v0.20.0
type CFTailRequest = cloudflare.CFTailRequest
Cloudflare provider & plan/tail types.
type CFTailResponse ¶ added in v0.20.0
type CFTailResponse = cloudflare.CFTailResponse
Cloudflare provider & plan/tail types.
type CloudflareProvider ¶
type CloudflareProvider = cloudflare.CloudflareProvider
Cloudflare provider & plan/tail types.
func NewCloudflareProvider ¶
func NewCloudflareProvider() *CloudflareProvider
NewCloudflareProvider creates a new Cloudflare serverless provider.
type ProbeOutcome ¶
type ProviderRules ¶
type ProviderRules struct {
Name string
Icon string
RootFormat string
WwwFormat string
SSLFormat func(record dns.ValidationRecord) string
Warning string
ProTip string
ProxyWarning string
}
ProviderRules holds DNS provider-specific display instructions.
type QueryOptions ¶ added in v1.2.0
type QueryOptions = cloudflare.QueryOptions
Cloudflare provider & plan/tail types.
type RollbackOptions ¶
type RollbackOptions = core.RollbackOptions
Core provider contract & shared report types.
type ServerlessResourceMap ¶
type ServerlessResourceMap = core.ServerlessResourceMap
Core provider contract & shared report types.
type SmokeOpts ¶
type SmokeOpts struct {
// MaxAttempts per URL. DNS + CF cache propagation can take a few
// seconds; 3 attempts spaced by Delay covers cold paths.
MaxAttempts int
// Delay between attempts for a single URL.
Delay time.Duration
// Timeout per individual HTTP request.
Timeout time.Duration
// FailOnError makes the smoke check fail the deploy on any non-2xx.
// Default false (warn-only) — deploys sometimes race with CF caching.
FailOnError bool
}
SmokeOpts tunes the post-deploy smoke check. Defaults are correct for typical deploys; tighten via the caller when fronting a CI workflow.
type SmokeResult ¶
type SmokeResult struct {
Probed []ProbeOutcome
Passed int
Failed int
}
SmokeResult is the summary a caller logs or surfaces in CI output.
func SmokeVerify ¶
func SmokeVerify( ctx context.Context, log *shared.Logger, cfg *config.NextDeployConfig, meta *nextcore.NextCorePayload, opts SmokeOpts, ) (*SmokeResult, error)
SmokeVerify probes a set of URLs derived from the app config + route manifest after a deploy completes. It's load-bearing for "did the deploy actually work" — the rest of the pipeline only proves the upload succeeded, not that the Worker responds.
Non-fatal by default. Operators opting into FailOnError make the deploy gate on this check.
type TailOptions ¶ added in v1.2.0
type TailOptions = cloudflare.TailOptions
Cloudflare provider & plan/tail types.
type UnmanagedResource ¶ added in v0.16.0
type UnmanagedResource = cloudflare.UnmanagedResource
Cloudflare provider & plan/tail types.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package aws implements the AWS Lambda, S3, and CloudFront serverless provider.
|
Package aws implements the AWS Lambda, S3, and CloudFront serverless provider. |
|
Package cloudflare implements the Cloudflare Workers and R2 serverless provider.
|
Package cloudflare implements the Cloudflare Workers and R2 serverless provider. |
|
adapter
Package adapter compiles and bundles Next.js standalone builds for Cloudflare Workers.
|
Package adapter compiles and bundles Next.js standalone builds for Cloudflare Workers. |
|
cfstate
Package cfstate is the persistent, encrypted record of the Cloudflare resources NextDeploy has provisioned (D1, KV, Hyperdrive, Queues, Vectorize, …) keyed by kind+name → real CF ID.
|
Package cfstate is the persistent, encrypted record of the Cloudflare resources NextDeploy has provisioned (D1, KV, Hyperdrive, Queues, Vectorize, …) keyed by kind+name → real CF ID. |
|
Package core defines the shared serverless provider contract, types, and local secret loading.
|
Package core defines the shared serverless provider contract, types, and local secret loading. |