proxyinstall

package
v0.8.5 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package proxyinstall plans and applies the start of a managed reverse proxy container through the Docker Engine API.

Index

Constants

View Source
const (
	EnvTraefikImage     = "APP_PROXY_TRAEFIK_IMAGE"
	DefaultTraefikImage = "traefik:v3.3.5"
)

EnvTraefikImage overrides DefaultTraefikImage, the pinned official image.

View Source
const (
	EntrypointHTTP  = "web"
	EntrypointHTTPS = "websecure"
	CertResolver    = "letsencrypt"
	UpstreamHost    = "host.docker.internal"

	LabelManaged = "managed-by"
	HTTPPort     = 80
	HTTPSPort    = 443

	RestartUnlessStopped = "unless-stopped"
	ProviderTraefik      = "traefik"
)

Fixed names of the proxy's own entry points and certificate resolver.

View Source
const (
	CodeUnsupportedProvider = "unsupported_provider"
	CodeInContainer         = "control_plane_in_container"
	CodePortBusy            = "port_in_use"
	CodeOwnIngress          = "port_held_by_builtin_ingress"
	CodeNameTaken           = "container_name_taken"
	CodeNoDataDir           = "no_data_dir"
)

Refusal codes a plan can carry.

Variables

This section is empty.

Functions

This section is empty.

Types

type Docker

type Docker interface {
	InspectByName(ctx context.Context, name string) (*docker.ContainerState, error)
	Create(ctx context.Context, spec docker.ContainerSpec) (string, error)
	Start(ctx context.Context, id string) error
	ListLocalContainers(ctx context.Context) ([]docker.LocalContainer, error)
}

Docker is the slice of the Engine API the install needs.

type File

type File struct {
	Path    string `json:"path"`
	Content string `json:"content"`
}

File is one file the install writes before the container starts.

type Input

type Input struct {
	Provider    string
	Image       string
	Brand       string
	DataDir     string
	PublicCerts bool
	ACMEEmail   string
}

Input is everything the plan depends on.

type Installer

type Installer struct {
	Docker Docker
	// PortHolder names what listens on a host TCP port, "" when free.
	PortHolder func(ctx context.Context, port int) string
	// OwnIngressPorts are the host ports the built-in ingress binds.
	OwnIngressPorts func() []int
	// InContainer is true when the control plane itself runs in Docker, so
	// its data dir is not a host path a new container could mount.
	InContainer bool
	MkdirAll    func(path string, perm os.FileMode) error
	WriteFile   func(path string, data []byte, perm os.FileMode) error
}

Installer plans and applies the install. Every host fact is injected.

func (*Installer) Apply

func (in *Installer) Apply(ctx context.Context, input Input) (Result, error)

Apply writes the files and creates and starts the container. A container it already made is started if stopped and otherwise left alone.

func (*Installer) Plan

func (in *Installer) Plan(ctx context.Context, input Input) (Plan, error)

Plan builds the plan and attaches a Refusal when the host cannot take it. A container this install already made is not a refusal: Apply is a no-op.

type Mount

type Mount struct {
	Host      string `json:"host"`
	Container string `json:"container"`
	ReadOnly  bool   `json:"read_only"`
}

Mount is one bind mount of the container.

type Plan

type Plan struct {
	Provider  string            `json:"provider"`
	Container string            `json:"container"`
	Image     string            `json:"image"`
	Ports     []int             `json:"ports"`
	Mounts    []Mount           `json:"mounts"`
	Files     []File            `json:"files"`
	Labels    map[string]string `json:"labels"`
	Restart   string            `json:"restart"`
	RouteDir  string            `json:"route_dir"`
	Resolver  string            `json:"cert_resolver"`
	Upstream  string            `json:"upstream_host"`
	Refusal   *Refusal          `json:"refusal,omitempty"`
}

Plan is the exact install: nothing in it is decided at apply time.

func BuildPlan

func BuildPlan(in Input) (Plan, error)

BuildPlan is pure: it only renders names, paths and file contents.

func (Plan) Spec

func (p Plan) Spec() docker.ContainerSpec

Spec converts the plan to the Docker container spec.

type Refusal

type Refusal struct {
	Code    string `json:"code"`
	Message string `json:"message"`
}

Refusal is a reason the install cannot proceed, with what to do instead.

func (*Refusal) Error

func (r *Refusal) Error() string

type Result

type Result struct {
	Plan    Plan   `json:"plan"`
	Created bool   `json:"created"`
	Started bool   `json:"started"`
	Detail  string `json:"detail"`
}

Result is what Apply did.

Jump to

Keyboard shortcuts

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