podman-openrc 0.1.1

A CLI tool to generate OpenRC scripts from Podman service definitions in (unofficial) TOML format.
podman-openrc-0.1.1 is not a library.

Podman OpenRC generator

This is a simple application written in Rust to convert a simple Podman service definition in TOML format to an OpenRC service script.

Installation

cargo install podman-openrc

Usage

podman-openrc <INPUT TOML FILE> <OUTPUT OPENRC FILE>
# For example: podman-openrc input.toml output.service.sh

TOML service description format

The TOML format describing a Podman service is non-standard. It is NOT a Podlet. The format is like this:

user = "<USERNAME>" # Optional property, set if you don't want to run the Podman command with the root user

# Required section
[service]
name = "<CONTAINER NAME>" # Container name, required
image = "<IMAGE>" # Podman image name
network = "<NETWORK>" # Optional, if you want to run the container within a specific network. Set to "host" if you don't want to use the podman networking.
depend = ["<SERVICE NAME>"] # Name of any service in /etc/init.d to depend on
restart = "unless-stopped" # Restart, optional. Defaults to "unless-stopped"
detach = true # Run container in detach mode, optional, default true. Recommended.
hostname = "<HOSTNAME>" # Host name, optional.
command = "<COMMAND>" # Container command to run, optional.

# Optionally set one or more environment variables
[environment]
ASPNETCORE_ENVIRONMENT = "Test"
# If you have a not TOML-compatible key name, use "" around the key name
 
# Optionally, you can assign one or more port mappings
[[ports]]
host = 80 # Port on your computer
container = 8080 # Port inside the container
protocol = "tcp" # Protocol, optional

# Optionally you can also assign volumes
[[volumes]]
volume = "<VOLUME NAME>" # Volume name or path on host
path = "<PATH>" # Volume location/target inside container

# Or you can make more advanced volumes with mounts
[[mounts]]
typ = "bind" # Mount type
source = "/etc/hosts" # Source file
target = "/etc/hosts" # Target file
read_only = true # Whether to use ro mode, optional

# Optionally you can use Podman secrets in an array
[[secrets]]
key = "<SECRET KEY>" # Secret key used in `podman secret`
target = "<TARGET SECRET FILE>" # Target secret filename in /var/run/secrets. Optional, defaults to the key

# Between environment and secrets: get secret from Podman and set it as environment variable
[[environment_secrets]]
name = "<ENV VARIABLE>" # Target environment variable name
secret = "<SECRET NAME>" # Secret key in `podman secret`

# Optionally, you can configure a healthcheck
[service.healthcheck]
cmd = "<HEALTHCHECK COMMAND>" # The command or route to run/check
interval = "5m" # Interval, optional
start_period = "30s" # Start period (start after), optional
retries = 3 # Max retries, optional
on_failure = "none" # On failure options, optional