docker

package
v2.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	VolumeAccessModeReadWrite = "rw"
	VolumeAccessModeReadOnly  = "ro"
)

Variables

This section is empty.

Functions

func EnvVar

func EnvVar(key string) string

func EnvVarInDocker

func EnvVarInDocker(key string) string

func GetDockerfileTemplate

func GetDockerfileTemplate(d Dockerfile) string

Types

type DockerCompose

type DockerCompose struct {
	Version  string   `yaml:"version"`
	Services Services `yaml:"services,omitempty"`
}

func NewDockerCompose

func NewDockerCompose() *DockerCompose

func (DockerCompose) AddService

func (dc DockerCompose) AddService(name string, s *Service) *DockerCompose

type Dockerfile

type Dockerfile struct {
	From       string            `docker:"FROM" yaml:"from,omitempty"`
	Image      string            `yaml:"image"`
	Label      map[string]string `docker:"LABEL,multi" yaml:"label,omitempty"`
	Run        string            `docker:"RUN,inline" yaml:"run,omitempty"`
	WorkDir    string            `docker:"WORKDIR" yaml:"workdir,omitempty"`
	Env        map[string]string `docker:"ENV,multi" yaml:"env,omitempty"`
	Add        map[string]string `docker:"ADD,join" yaml:"add,omitempty"`
	Expose     []string          `docker:"EXPOSE" yaml:"expose,omitempty"`
	Volume     []string          `docker:"VOLUME,array" yaml:"volume,omitempty"`
	Cmd        []string          `docker:"CMD,array" yaml:"cmd,omitempty"`
	EntryPoint []string          `docker:"ENTRYPOINT,array" yaml:"entrypoint,omitempty"`
}

func (Dockerfile) AddContent

func (d Dockerfile) AddContent(from string, to string) *Dockerfile

func (Dockerfile) AddEnv

func (d Dockerfile) AddEnv(key string, value string) *Dockerfile

func (Dockerfile) AddLabel

func (d Dockerfile) AddLabel(label string, content string) *Dockerfile

func (*Dockerfile) String

func (d *Dockerfile) String() string

func (Dockerfile) WithCmd

func (d Dockerfile) WithCmd(cmd ...string) *Dockerfile

func (Dockerfile) WithExpose

func (d Dockerfile) WithExpose(exposes ...string) *Dockerfile

func (Dockerfile) WithVolume

func (d Dockerfile) WithVolume(volumes ...string) *Dockerfile

func (Dockerfile) WithWorkDir

func (d Dockerfile) WithWorkDir(dir string) *Dockerfile

type Image

type Image struct {
	Name    string
	Version string
}

func ParseImageString

func ParseImageString(s string) (*Image, error)

func (Image) IsZero

func (image Image) IsZero() bool

func (Image) MarshalYAML

func (i Image) MarshalYAML() (interface{}, error)

func (Image) String

func (i Image) String() string

func (*Image) UnmarshalYAML

func (i *Image) UnmarshalYAML(unmarshal func(interface{}) error) error
type Link struct {
	Service string
	Host    string
}

func ParseLinkString

func ParseLinkString(s string) (*Link, error)

func (Link) MarshalYAML

func (link Link) MarshalYAML() (interface{}, error)

func (Link) String

func (link Link) String() string

func (*Link) UnmarshalYAML

func (link *Link) UnmarshalYAML(unmarshal func(interface{}) error) error

type MaybeListString

type MaybeListString struct {
	// contains filtered or unexported fields
}

func MaybeListStringFromStringList

func MaybeListStringFromStringList(list ...string) MaybeListString

func (MaybeListString) IsZero

func (v MaybeListString) IsZero() bool

func (MaybeListString) MarshalYAML

func (v MaybeListString) MarshalYAML() (interface{}, error)

func (*MaybeListString) UnmarshalYAML

func (v *MaybeListString) UnmarshalYAML(unmarshal func(interface{}) error) error

func (MaybeListString) Value

func (v MaybeListString) Value() []string

type Port

type Port struct {
	Port          int16
	ContainerPort int16
	Protocol      Protocol
}

func ParsePortString

func ParsePortString(s string) (*Port, error)

func (Port) MarshalYAML

func (port Port) MarshalYAML() (interface{}, error)

func (Port) String

func (port Port) String() string

func (*Port) UnmarshalYAML

func (port *Port) UnmarshalYAML(unmarshal func(interface{}) error) error

type Protocol

type Protocol string
const (
	ProtocolTCP Protocol = "TCP"
	ProtocolUDP Protocol = "UDP"
)

type Service

type Service struct {
	Image          Image             `yaml:"image"`
	EntryPoint     MaybeListString   `yaml:"entrypoint,omitempty"`
	Command        MaybeListString   `yaml:"command,omitempty"`
	Labels         map[string]string `yaml:"labels,omitempty"`
	Environment    map[string]string `yaml:"environment,omitempty"`
	Ports          []Port            `yaml:"ports,omitempty"`
	Links          []Link            `yaml:"links,omitempty"`
	ExternalLinks  []Link            `yaml:"external_links,omitempty"`
	Volumes        []Volume          `yaml:"volumes,omitempty"`
	VolumesFrom    []Volume          `yaml:"volumes_from,omitempty"`
	WorkingDir     string            `yaml:"working_dir,omitempty"`
	DnsSearch      []string          `yaml:"dns_search,omitempty"`
	Dns            []string          `yaml:"dns,omitempty"`
	TTY            *bool             `yaml:"tty,omitempty"`
	MemLimit       *int64            `yaml:"mem_limit,omitempty"`
	MemSwapLimit   *int64            `yaml:"memswap_limit,omitempty"`
	MemReservation *int64            `yaml:"mem_reservation,omitempty"`
}

func NewService

func NewService(image string) *Service

func (Service) AddDns

func (service Service) AddDns(dns string, dnsSearch string) *Service
func (service Service) AddExternalLink(s string, host string) *Service
func (service Service) AddLink(s string, host string) *Service

func (Service) AddROVolume

func (service Service) AddROVolume(nameOrLocalPath string, mountPath string) *Service

func (Service) AddRWVolume

func (service Service) AddRWVolume(nameOrLocalPath string, mountPath string) *Service

func (Service) AddTCPPort

func (service Service) AddTCPPort(port int16, containerPort int16) *Service

func (Service) AddUDPPort

func (service Service) AddUDPPort(port int16, containerPort int16) *Service

func (Service) AddVolumeFrom

func (service Service) AddVolumeFrom(name string, accessMode VolumeAccessMode) *Service

func (Service) EnableTTY

func (service Service) EnableTTY() *Service

func (Service) Merge

func (service Service) Merge(nextService *Service) *Service

func (Service) SetCommand

func (service Service) SetCommand(commands ...string) *Service

func (Service) SetEnvironment

func (service Service) SetEnvironment(key string, value string) *Service

func (Service) SetLabel

func (service Service) SetLabel(key string, value string) *Service

func (Service) WithImage

func (service Service) WithImage(image string) *Service

type Services

type Services map[string]*Service

func (*Services) UnmarshalYAML

func (v *Services) UnmarshalYAML(unmarshal func(interface{}) error) error

type Volume

type Volume struct {
	Name       string
	LocalPath  string
	MountPath  string
	AccessMode VolumeAccessMode
}

func ParseVolumeString

func ParseVolumeString(s string) (*Volume, error)

func (Volume) IsMountFromLocal

func (v Volume) IsMountFromLocal() bool

func (Volume) IsMountFromStorage

func (v Volume) IsMountFromStorage() bool

func (Volume) IsProvider

func (v Volume) IsProvider() bool

func (Volume) MarshalYAML

func (v Volume) MarshalYAML() (interface{}, error)

func (Volume) ReadOnly

func (v Volume) ReadOnly() bool

func (Volume) String

func (v Volume) String() string

func (*Volume) UnmarshalYAML

func (v *Volume) UnmarshalYAML(unmarshal func(interface{}) error) error

type VolumeAccessMode

type VolumeAccessMode string

Jump to

Keyboard shortcuts

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