registry/start.sh

42 lines
1 KiB
Bash
Raw Permalink Normal View History

#!/bin/bash
service_name=$(jq .service_name ./service.json -r)
image_name=$service_name
image_version=${IMAGE_VERSION:-local}
auth_volume="$service_name"_auth
data_volume="$service_name"_data
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
podman volume exists "$data_volume"
if [[ "$?" != "1" ]]; then
echo "Volume $data_volume already exists."
else
podman volume create "$data_volume"
echo "Created volume $data_volume."
fi
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 \
-v "$data_volume":/var/lib/registry \
"$image_name:$image_version"