From 484f9931d295451d93383db241b06c1b7ff59799 Mon Sep 17 00:00:00 2001 From: Marc Cataford Date: Tue, 9 Apr 2024 00:02:12 -0400 Subject: [PATCH] feat: add volume for registry persistence --- .forgejo/workflows/ci.yml | 2 +- start.sh | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.forgejo/workflows/ci.yml b/.forgejo/workflows/ci.yml index 3531f88..6ac995b 100644 --- a/.forgejo/workflows/ci.yml +++ b/.forgejo/workflows/ci.yml @@ -18,4 +18,4 @@ jobs: - name: Authenticate with registry run: podman login -u srv_container-registry -p ${{ secrets.REGISTRY_TOKEN }} ${{ env.CONTAINER_ADDRESS }} - name: Push image - run: podman push container-registry:0 ${{ env.CONTAINER_ADDRESS }}/container-registry:0 + run: podman push container-registry:0 ${{ env.CONTAINER_ADDRESS }}/container-registry:${{ env.GITHUB_REF_NAME }} diff --git a/start.sh b/start.sh index 2d89128..0ab0f5f 100755 --- a/start.sh +++ b/start.sh @@ -5,6 +5,7 @@ image_name=$service_name image_version=0 auth_volume="$service_name"_auth +data_volume="$service_name"_data podman volume exists "$auth_volume" @@ -17,6 +18,16 @@ else 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" + htpasswd_parent=$(podman volume inspect "$data_volume" | jq '.[0].Mountpoint' -r) + echo "Created volume $data_volume." +fi + podman pod create \ --name "$service_name" \ --replace \ @@ -27,4 +38,5 @@ podman run \ --pod "$service_name" \ --name "$service_name"_app \ -v "$auth_volume":/auth:ro \ + -v "$data_volume":/var/lib/registry \ "$image_name:$image_version"