melon/container
Types
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 to represent a memory unit.
pub type MemoryUnit {
Byte
Kilobyte
Megabyte
Gigabyte
}
Constructors
-
Byte
-
Kilobyte
-
Megabyte
-
Gigabyte
The type that holds information about a port.
pub type Port {
Port(host: String, value: Int, protocol: PortProtocol)
}
Constructors
-
Port(host: String, value: Int, 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: Int,
protocol protocol: PortProtocol,
) -> Container
Adds an exposed port to the given container.
pub fn mapped_port(
container: Container,
port port: Int,
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_env_file(
container: Container,
env_file: String,
) -> Container
Sets the environment file of a given container.
pub fn set_health_check_command(
container: Container,
command: List(String),
) -> Container
Sets the health check command of the given container.
pub fn set_health_check_interval(
container: Container,
interval interval: Int,
unit unit: TimeUnit,
) -> Container
Sets the health check interval of the given container.
pub fn set_health_check_retries(
container: Container,
retries: Int,
) -> Container
Sets the health check retry count of the given container.
pub fn set_health_check_start_period(
container: Container,
start_period start_period: Int,
unit unit: TimeUnit,
) -> Container
Sets the health check start period of the given container.
pub fn set_health_check_timeout(
container: Container,
timeout timeout: Int,
unit unit: TimeUnit,
) -> Container
Sets the health check timeout of the given container.
pub fn set_memory_limit(
container: Container,
limit limit: Int,
unit unit: MemoryUnit,
) -> Container
Sets the memory limit 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.