Instead of inferring the gateway ip via the the network device for
the podman bridge, where the name can change, use podman network
inspect.
```js
The json looks like this:
[
{
"cniVersion": "0.4.0",
"name": "org.osbuild.koji",
"plugins": [
{
"bridge": "cni-podman1",
"hairpinMode": true,
"ipMasq": true,
"ipam": {
"ranges": [
[
{
"gateway": "10.89.0.1",
"subnet": "10.89.0.0/24"
}
]
],
"routes": [
{
"dst": "0.0.0.0/0"
}
],
"type": "host-local"
},
"isGateway": true,
"type": "bridge"
},
{
"capabilities": {
"portMappings": true
},
"type": "portmap"
},
{
"backend": "",
"type": "firewall"
},
{
"domainName": "dns.podman",
"type": "dnsname"
}
]
}
]
```
So the podman format for this is very obviously:
{{ (index (index (index .plugins 0).ipam.ranges 0) 0).gateway }}
31 lines
962 B
Bash
Executable file
31 lines
962 B
Bash
Executable file
#!/usr/bin/bash
|
|
|
|
SHARE_DIR=/tmp/osbuild-composer-koji-test
|
|
DATA_DIR=/var/tmp/osbuild-koji-data
|
|
|
|
# this script must be run as root
|
|
if [ $UID != 0 ]; then
|
|
echo This script must be run as root.
|
|
exit 1
|
|
fi
|
|
|
|
# decide whether podman or docker should be used
|
|
if which podman 2>/dev/null >&2; then
|
|
CONTAINER_RUNTIME=podman
|
|
elif which docker 2>/dev/null >&2; then
|
|
CONTAINER_RUNTIME=docker
|
|
else
|
|
echo No container runtime found, install podman or docker.
|
|
exit 2
|
|
fi
|
|
|
|
GATEWAY_IP=$(podman network inspect org.osbuild.koji --format '{{ (index (index (index .plugins 0).ipam.ranges 0) 0).gateway }}')
|
|
echo "Gateway IP is $GATEWAY_IP"
|
|
|
|
${CONTAINER_RUNTIME} run --rm -i -t --name org.osbuild.koji.builder --network org.osbuild.koji \
|
|
-v "${SHARE_DIR}:/share:z" \
|
|
-v "${DATA_DIR}:/mnt:z" \
|
|
-v "${PWD}/container/builder/osbuild-koji.conf:/etc/koji-osbuild/builder.conf:z" \
|
|
--hostname org.osbuild.koji.kojid \
|
|
--add-host=composer:${GATEWAY_IP} \
|
|
koji.builder
|