dockergen

package
v0.0.0-...-f078915 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: BSD-3-Clause Imports: 11 Imported by: 0

README

dockergen

import "github.com/blueprint-uservices/blueprint/plugins/dockercompose/dockergen"

Index

func ExecuteTemplate

func ExecuteTemplate(name string, body string, args any) (string, error)

func ExecuteTemplateToFile

func ExecuteTemplateToFile(name string, body string, args any, filename string) error

type DockerComposeFile

Used for generating the docker-compose file of a docker app

type DockerComposeFile struct {
    WorkspaceName string
    WorkspaceDir  string
    FileName      string
    FilePath      string
    Instances     map[string]instance // Container instance declarations
    // contains filtered or unexported fields
}

func NewDockerComposeFile
func NewDockerComposeFile(workspaceName, workspaceDir, fileName string) *DockerComposeFile

func (*DockerComposeFile) AddBuildInstance
func (d *DockerComposeFile) AddBuildInstance(instanceName string, containerTemplateName string, args ...ir.IRNode) error

func (*DockerComposeFile) AddEnvVar
func (d *DockerComposeFile) AddEnvVar(instanceName string, key string, val string) error

func (*DockerComposeFile) AddImageInstance
func (d *DockerComposeFile) AddImageInstance(instanceName string, image string, args ...ir.IRNode) error

func (*DockerComposeFile) Generate
func (d *DockerComposeFile) Generate() error

func (*DockerComposeFile) ResolveLocalDials
func (d *DockerComposeFile) ResolveLocalDials() error

Generated by gomarkdoc

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecuteTemplate

func ExecuteTemplate(name string, body string, args any) (string, error)

func ExecuteTemplateToFile

func ExecuteTemplateToFile(name string, body string, args any, filename string) error

Types

type DockerComposeFile

type DockerComposeFile struct {
	WorkspaceName string
	WorkspaceDir  string
	FileName      string
	FilePath      string
	Instances     map[string]*instance // Container instance declarations
	// contains filtered or unexported fields
}

Used for generating the docker-compose file of a docker app

func NewDockerComposeFile

func NewDockerComposeFile(workspaceName, workspaceDir, fileName string) *DockerComposeFile

func (*DockerComposeFile) AddBuildInstance

func (d *DockerComposeFile) AddBuildInstance(instanceName string, containerTemplateName string) error

Adds an instance to the docker-compose file, that will be built from a container template on the local filesystem

The instanceName is chosen by the user; it can subsequently be passed in methods such as [AddEnvVar], [PassthroughEnvVar], [ExposePort], [MapPort], and [MapPortToEnvVar].

func (*DockerComposeFile) AddEnvVar

func (d *DockerComposeFile) AddEnvVar(instanceName string, key string, val string) error

Sets an environment variable key to the specified val for instanceName

func (*DockerComposeFile) AddImageInstance

func (d *DockerComposeFile) AddImageInstance(instanceName string, image string) error

Adds an instance to the docker-compose file, that will use an off-the-shelf image.

The instanceName is chosen by the user; it can subsequently be passed in methods such as [AddEnvVar], [PassthroughEnvVar], [ExposePort], [MapPort], and [MapPortToEnvVar].

func (*DockerComposeFile) ExposePort

func (d *DockerComposeFile) ExposePort(instanceName string, internalPort uint16) error

Exposes a container-internal port for use by other containers within the docker-compose file

func (*DockerComposeFile) Generate

func (d *DockerComposeFile) Generate() error

func (*DockerComposeFile) MapPort

func (d *DockerComposeFile) MapPort(instanceName string, internalPort uint16, externalAddress string) error

Further to [ExposePort], adds a Port directive so that the host machine can access the internalPort of the container via the externalAddress. Typically externalAddress will be a localhost or 0.0.0.0 address

func (*DockerComposeFile) MapPortToEnvVar

func (d *DockerComposeFile) MapPortToEnvVar(instanceName string, internalPort uint16, envVarName string) error

Further to [ExposePort], adds a Port directive so that the host machine can access the internalPort of the container, using a runtime substitution of envVarName as the externalAddress

func (*DockerComposeFile) PassthroughEnvVar

func (d *DockerComposeFile) PassthroughEnvVar(instanceName string, key string, optional bool) error

Pass through the specified environment variable key from the calling environment

Jump to

Keyboard shortcuts

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