Documentation
¶
Overview ¶
Package docker deploys apps to a Docker engine, local or remote over SSH.
Index ¶
- func SSHHostname(target string) string
- type AppImage
- type ContainerInfo
- type ContainerMeta
- type ContainerResource
- type ContainerRuntime
- type DBRunSpec
- type Engine
- func (e *Engine) AppContainerKeys() (map[string]string, error)
- func (e *Engine) AppContainers(app string) []string
- func (e *Engine) AppImageTags(app string) []string
- func (e *Engine) AppImages() ([]AppImage, error)
- func (e *Engine) AppResourceStats() ([]ContainerResource, error)
- func (e *Engine) AppStates() (map[string]string, error)
- func (e *Engine) Available() error
- func (e *Engine) BuildFromDockerfile(ctx context.Context, tag, dockerfile, contextDir string, out io.Writer) error
- func (e *Engine) ConnectNetwork(network, container string) error
- func (e *Engine) ContainerImages() (map[string]bool, error)
- func (e *Engine) ContainerMeta(name string) (ContainerMeta, error)
- func (e *Engine) Containers() ([]string, error)
- func (e *Engine) EnsureNetwork(name string) error
- func (e *Engine) Exec(ctx context.Context, container string, cmd []string, stdin io.Reader, ...) error
- func (e *Engine) HostPort(name string, containerPort int) (int, error)
- func (e *Engine) ImageExists(tag string) bool
- func (e *Engine) IsRemote() bool
- func (e *Engine) Logs(container string, follow bool, tail string, out io.Writer) error
- func (e *Engine) PruneBuildCache(olderThan time.Duration) error
- func (e *Engine) PruneDanglingImages() error
- func (e *Engine) PullImage(image string) error
- func (e *Engine) Remove(name string) error
- func (e *Engine) RemoveImage(tag string) error
- func (e *Engine) RemoveVolume(name string) error
- func (e *Engine) Routes() ([]Route, error)
- func (e *Engine) Run(s RunSpec) (int, error)
- func (e *Engine) RunDatabase(s DBRunSpec) (int, error)
- func (e *Engine) RunOnce(ctx context.Context, image string, env map[string]string, network, cmd string) (string, error)
- func (e *Engine) RunTool(network string, env map[string]string, image string, args ...string) (string, error)
- func (e *Engine) RunWorker(s WorkerSpec) error
- func (e *Engine) RunningContainers() ([]string, error)
- func (e *Engine) Runtime(name string) (ContainerRuntime, error)
- func (e *Engine) SkiffContainers() []ContainerInfo
- func (e *Engine) Start(container string) error
- func (e *Engine) State(container string) string
- func (e *Engine) StatsFor(appOf map[string]string) ([]ContainerResource, error)
- func (e *Engine) Stop(container string) error
- func (e *Engine) StreamLogs(ctx context.Context, container string, out io.Writer) error
- func (e *Engine) StreamLogsSSE(ctx context.Context, container string, w io.Writer, flush func())
- func (e *Engine) Tag(src, dst string) error
- func (e *Engine) WorkerContainers(app string) []string
- type Mount
- type Route
- type RunSpec
- type WorkerSpec
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SSHHostname ¶
Types ¶
type ContainerInfo ¶
type ContainerMeta ¶ added in v0.2.0
type ContainerResource ¶
type ContainerRuntime ¶ added in v0.2.0
type DBRunSpec ¶
type DBRunSpec struct {
Name string
Image string
Network string
Volume string // named volume for persistence
MountAt string // where the volume mounts inside the container
Env map[string]string
Cmd []string // optional command/args after the image
Labels map[string]string // ownership + kind labels
Port int // container port (published on the host when Publish is set)
Publish bool // expose Port on 0.0.0.0 for external access
Entrypoint string // optional --entrypoint override (e.g. "sh" to fix TLS cert perms)
Binds []string // extra bind mounts, "host:container[:ro]" (e.g. the TLS cert dir)
}
DBRunSpec runs a managed resource (a database), deliberately unlabeled with skiff=1 so the app reaper leaves it alone.
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
func (*Engine) AppContainerKeys ¶ added in v0.2.0
AppContainerKeys maps each running app container to its app.
func (*Engine) AppContainers ¶
AppContainers lists every container (running or not) for an app, so all stale versions get retired, not just the registry's last-recorded one.
func (*Engine) AppImageTags ¶
AppImageTags lists an app's retained image tags (excluding :latest and <none>), relying on docker's default created-descending order — newest first — for pruning.
func (*Engine) AppImages ¶ added in v0.2.0
AppImages lists every skiff-<app> image tag on the engine.
func (*Engine) AppResourceStats ¶
func (e *Engine) AppResourceStats() ([]ContainerResource, error)
func (*Engine) AppStates ¶
AppStates maps each skiff app to its container state; running wins when an app has more than one container (e.g. mid-rollout).
func (*Engine) BuildFromDockerfile ¶
func (*Engine) ConnectNetwork ¶
ConnectNetwork attaches a container to an additional network; an already-connected container returns a benign error.
func (*Engine) ContainerImages ¶ added in v0.2.0
ContainerImages returns the image of every container, running or not.
func (*Engine) ContainerMeta ¶ added in v0.2.0
func (e *Engine) ContainerMeta(name string) (ContainerMeta, error)
func (*Engine) Containers ¶
func (*Engine) EnsureNetwork ¶
func (*Engine) Exec ¶
func (e *Engine) Exec(ctx context.Context, container string, cmd []string, stdin io.Reader, stdout io.Writer) error
Exec runs a command inside a container, wiring stdin/stdout to the given streams — used to dump a database and pipe a dump back in.
func (*Engine) ImageExists ¶
func (*Engine) PruneBuildCache ¶ added in v0.2.0
func (*Engine) PruneDanglingImages ¶ added in v0.2.0
func (*Engine) RemoveImage ¶
func (*Engine) RemoveVolume ¶
func (*Engine) RunDatabase ¶
RunDatabase (re)creates a managed database container, returning the published host port when Publish is set (0 otherwise); reusing the same name + volume preserves the data.
func (*Engine) RunOnce ¶
func (e *Engine) RunOnce(ctx context.Context, image string, env map[string]string, network, cmd string) (string, error)
RunOnce runs a throwaway container executing a shell command (sh -c), for release commands (migrations) and scheduled jobs.
func (*Engine) RunTool ¶
func (e *Engine) RunTool(network string, env map[string]string, image string, args ...string) (string, error)
RunTool runs a throwaway container passing args straight to the entrypoint (no shell), for CLI images like minio/mc that have none.
func (*Engine) RunWorker ¶
func (e *Engine) RunWorker(s WorkerSpec) error
func (*Engine) RunningContainers ¶ added in v0.2.0
RunningContainers names every running container.
func (*Engine) Runtime ¶ added in v0.2.0
func (e *Engine) Runtime(name string) (ContainerRuntime, error)
Runtime reads how a container was started: image, environment, command, networks and volumes.
func (*Engine) SkiffContainers ¶
func (e *Engine) SkiffContainers() []ContainerInfo
func (*Engine) StatsFor ¶ added in v0.2.0
func (e *Engine) StatsFor(appOf map[string]string) ([]ContainerResource, error)
StatsFor samples the named containers once, reporting each under the key it maps to.
func (*Engine) StreamLogs ¶
func (*Engine) StreamLogsSSE ¶
func (*Engine) WorkerContainers ¶
WorkerContainers lists an app's worker containers (running or not); all of them when app is "".
type RunSpec ¶
type RunSpec struct {
Name string
App string // app name, for the skiff.app route label
Image string
ContainerPort int
Memory string // optional, e.g. "512m"
CPU string // optional, e.g. "0.5"
Env map[string]string
Public bool // publish on all interfaces instead of 127.0.0.1
Network string // optional docker network to join (for reaching managed resources by name)
Labels map[string]string
}