91 lines
3.2 KiB
Markdown
91 lines
3.2 KiB
Markdown
# 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
|
|
```sh
|
|
cargo install podman-openrc
|
|
```
|
|
|
|
# Usage
|
|
```sh
|
|
podman-openrc <INPUT TOML FILE> <OUTPUT OPENRC FILE>
|
|
# For example: podman-openrc input.toml output.service
|
|
|
|
# or:
|
|
podman-openrc ./input-folder /etc/init.d
|
|
```
|
|
|
|
# TOML service description format
|
|
The TOML format describing a Podman service is non-standard. It is NOT a Podlet.
|
|
The format is like this:
|
|
|
|
```toml
|
|
user = "<USERNAME>" # Optional property, set if you don't want to run the Podman command with the root user
|
|
capabilities = ["NET_BIND_SERVICE"] # Optional property, add Linux capabilities if you need some
|
|
|
|
# Required section
|
|
[service]
|
|
name = "<CONTAINER NAME>" # Container name, required
|
|
image = "<IMAGE>" # Podman image name
|
|
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.
|
|
interactive = false # Run container in interactive mode, optional, default false
|
|
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
|
|
|
|
# Optional, if you want to run the container within specific network(s). Set to "host" if you don't want to use the podman networking.
|
|
[[networks]]
|
|
name = "host"
|
|
|
|
# You can also create groups
|
|
[[networks]]
|
|
name = "netw-service-test"
|
|
group = "http-networks"
|
|
|
|
# And assign ALL networks assigned to a group to a service
|
|
[[networks]]
|
|
group = "http-networks"
|
|
|
|
# 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]]
|
|
source = "<VOLUME NAME>" # Volume name or path on host
|
|
target = "<PATH>" # Volume location/target inside container
|
|
create = true # Optional, set to true if volume is NOT a path but named volume and you want to create it
|
|
|
|
# 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
|
|
``` |