2024-04-08 23:38:48 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
service_name=$(jq .service_name ./service.json -r)
|
|
|
|
image_name=$service_name
|
|
|
|
image_version=0
|
|
|
|
|
|
|
|
auth_volume="$service_name"_auth
|
2024-04-09 04:02:12 +00:00
|
|
|
data_volume="$service_name"_data
|
2024-04-08 23:38:48 +00:00
|
|
|
|
|
|
|
podman volume exists "$auth_volume"
|
|
|
|
|
|
|
|
if [[ "$?" != "1" ]]; then
|
|
|
|
echo "Volume $auth_volume already exists."
|
|
|
|
else
|
|
|
|
podman volume create "$auth_volume"
|
|
|
|
htpasswd_parent=$(podman volume inspect "$auth_volume" | jq '.[0].Mountpoint' -r)
|
|
|
|
touch "$htpasswd_parent"/htpasswd
|
|
|
|
echo "Created volume $auth_volume and seeded with empty htpasswd."
|
|
|
|
fi
|
|
|
|
|
2024-04-09 04:02:12 +00:00
|
|
|
podman volume exists "$data_volume"
|
|
|
|
|
|
|
|
if [[ "$?" != "1" ]]; then
|
|
|
|
echo "Volume $data_volume already exists."
|
|
|
|
else
|
|
|
|
podman volume create "$data_volume"
|
|
|
|
htpasswd_parent=$(podman volume inspect "$data_volume" | jq '.[0].Mountpoint' -r)
|
|
|
|
echo "Created volume $data_volume."
|
|
|
|
fi
|
|
|
|
|
2024-04-08 23:38:48 +00:00
|
|
|
podman pod create \
|
|
|
|
--name "$service_name" \
|
|
|
|
--replace \
|
|
|
|
-p 5000:5000 \
|
|
|
|
|
|
|
|
podman run \
|
|
|
|
-td \
|
|
|
|
--pod "$service_name" \
|
|
|
|
--name "$service_name"_app \
|
|
|
|
-v "$auth_volume":/auth:ro \
|
2024-04-09 04:02:12 +00:00
|
|
|
-v "$data_volume":/var/lib/registry \
|
2024-04-08 23:38:48 +00:00
|
|
|
"$image_name:$image_version"
|