melon/container

Types

The type that holds information about a container.

pub opaque type Container

The error type to represent a reason why a container operation failed.

pub type ContainerFailure {
  ContainerIsNotRunning
  ContainerCouldNotBeStarted(reason: String)
  ContainerCouldNotBeStopped(reason: String)
  MappedPortCouldNotBeFound
}

Constructors

  • ContainerIsNotRunning
  • ContainerCouldNotBeStarted(reason: String)
  • ContainerCouldNotBeStopped(reason: String)
  • MappedPortCouldNotBeFound

The type that holds information about a port.

pub type Port {
  Port(host: String, value: String, protocol: PortProtocol)
}

Constructors

  • Port(host: String, value: String, protocol: PortProtocol)

The type to specify the protocol a port is exposed via.

pub type PortProtocol {
  Tcp
  Udp
  Sctp
}

Constructors

  • Tcp
  • Udp
  • Sctp

Functions

pub fn add_env(
  container: Container,
  name identifier: String,
  value value: String,
) -> Container

Adds an environment variable to the given container.

pub fn add_exposed_port(
  container: Container,
  host host: String,
  port port: String,
  protocol protocol: PortProtocol,
) -> Container

Adds an exposed port to the given container.

pub fn mapped_port(
  container: Container,
  port port: String,
  protocol protocol: PortProtocol,
) -> Result(Port, ContainerFailure)

Returns a mapped port of the given container.

pub fn new(image: String) -> Container

Creates a new container using the given image.

Remaining properties of the container can be configured via various setter functions in this module.

pub fn set_command(
  container: Container,
  command: List(String),
) -> Container

Sets the command of the given container.

pub fn set_entrypoint(
  container: Container,
  entrypoint: String,
) -> Container

Sets the entrypoint of the given container.

pub fn set_user(container: Container, user: String) -> Container

Sets the user of the given container.

pub fn set_working_directory(
  container: Container,
  working_directory: String,
) -> Container

Sets the working directory of the given container.

pub fn start(
  container: Container,
) -> Result(Container, ContainerFailure)

Starts the given container.

pub fn stop(
  container: Container,
) -> Result(Container, ContainerFailure)

Stops the given container.

Search Document