Documentation
¶
Overview ¶
Package docker wraps the Docker engine SDK and the AWS ECR SDK to build the Gothic Lambda image and push it to Elastic Container Registry. It replaces the `sam build` + ECR push previously performed by the SAM CLI.
Provider Dockerfiles are embedded in the CLI binary (never seeded to a user's project on disk). They are selected at build time by the deployment provider (e.g. "aws", "gcp"). A user may override the embedded Dockerfile by setting DockerfilePath in gothic.config.go.
Index ¶
- Variables
- type DockerEngine
- func (e *DockerEngine) BuildImage(ctx context.Context, ...) error
- func (e *DockerEngine) CheckDaemon(ctx context.Context) error
- func (e *DockerEngine) Close() error
- func (e *DockerEngine) EnsureECRRepo(ctx context.Context, awsCfg aws.Config, repoName string) (string, error)
- func (e *DockerEngine) PushImage(ctx context.Context, awsCfg aws.Config, imageURI string) error
Constants ¶
This section is empty.
Variables ¶
var DockerfileFS embed.FS
DockerfileFS holds the provider-specific Dockerfiles compiled into the binary.
Functions ¶
This section is empty.
Types ¶
type DockerEngine ¶
type DockerEngine struct {
// contains filtered or unexported fields
}
DockerEngine builds the Gothic Lambda image and pushes it to ECR.
func NewDockerEngine ¶
func NewDockerEngine() (*DockerEngine, error)
NewDockerEngine constructs a DockerEngine connected to the local Docker daemon via environment configuration, negotiating the API version with the daemon.
func (*DockerEngine) BuildImage ¶
func (e *DockerEngine) BuildImage(ctx context.Context, projectRoot, dockerfilePath, imageName, tag, provider string) error
BuildImage builds the container image for the given provider. dockerfilePath, when non-empty, overrides the embedded provider Dockerfile. The image is tagged as imageName:tag.
func (*DockerEngine) CheckDaemon ¶
func (e *DockerEngine) CheckDaemon(ctx context.Context) error
CheckDaemon verifies the Docker daemon is reachable. The returned error always contains the substring "Docker daemon is not running" so callers and tests can assert on it.
func (*DockerEngine) Close ¶
func (e *DockerEngine) Close() error
Close releases the underlying Docker client resources.
func (*DockerEngine) EnsureECRRepo ¶
func (e *DockerEngine) EnsureECRRepo(ctx context.Context, awsCfg aws.Config, repoName string) (string, error)
EnsureECRRepo returns the URI of the ECR repository named repoName, creating it if it does not already exist.
func (*DockerEngine) PushImage ¶
PushImage authenticates against ECR and pushes the exact image reference given (repo:<immutable-tag>). Mid-stream push failures (which the Docker SDK reports inside the JSON stream rather than as a Go error) are surfaced as errors.
The reference MUST be immutable (a unique per-deploy tag), never repo:latest: an image-based Lambda pins to the digest resolved at apply time and does not re-pull a moving tag, and a constant image_uri string makes tofu see no diff on redeploy — so the Lambda would keep running the previous image forever.