fixed docker registry access
Some checks failed
ci/woodpecker/push/db Pipeline failed

This commit is contained in:
Stephan D
2025-11-07 01:32:31 +01:00
parent dbc77a7156
commit 2954dcde7b
2 changed files with 49 additions and 18 deletions

View File

@@ -35,24 +35,7 @@ steps:
REGISTRY_URL: registry.sendico.io
MONGO_VERSION: latest
commands:
- |
set -euo
mkdir -p ci/prod/env
set -a
. ./ci/prod/.env.runtime
. ./.env.version
set +a
test -s secrets/REGISTRY_USER && test -s secrets/REGISTRY_PASS
CREDS="$(cat secrets/REGISTRY_USER):$(cat secrets/REGISTRY_PASS)"
skopeo copy --all \
docker://docker.io/library/mongo:${MONGO_VERSION} \
docker://${REGISTRY_URL}/mirror/mongo:${APP_V} \
--dest-creds "$CREDS"
INSPECT=$(skopeo inspect docker://${REGISTRY_URL}/mirror/mongo:${APP_V} --creds "$CREDS")
DIGEST="$(printf '%s' "$INSPECT" | tr -d '\n' | sed -n 's/.*"Digest"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p')"
test -n "$DIGEST"
printf 'MONGO_TAG=%s\nMONGO_DIGEST=%s\n' "$APP_V" "$DIGEST" | tee .env.lock ci/prod/env/.env.lock.db
cat .env.lock
- bash ci/prod/scripts/lock-db.sh
- name: deploy
image: alpine:latest

View File

@@ -0,0 +1,48 @@
#!/usr/bin/env bash
set -euo pipefail
mkdir -p ci/prod/env
# export runtime vars (SSH_HOST etc.) and version info for downstream steps
set -a
. ./ci/prod/.env.runtime
. ./.env.version
set +a
REGISTRY_URL="${REGISTRY_URL:-}"
MONGO_VERSION="${MONGO_VERSION:-latest}"
APP_V="${APP_V:-}"
if [ -z "$REGISTRY_URL" ]; then
echo "REGISTRY_URL is not set (define in .env.runtime or Woodpecker env)" >&2
exit 1
fi
if [ -z "$APP_V" ]; then
echo "APP_V is not set (version step must run first)" >&2
exit 1
fi
for f in secrets/REGISTRY_USER secrets/REGISTRY_PASS; do
if [ ! -s "$f" ]; then
echo "missing registry credential: $f" >&2
exit 1
fi
done
CREDS="$(cat secrets/REGISTRY_USER):$(cat secrets/REGISTRY_PASS)"
skopeo copy --all \
"docker://docker.io/library/mongo:${MONGO_VERSION}" \
"docker://${REGISTRY_URL}/mirror/mongo:${APP_V}" \
--dest-creds "$CREDS"
INSPECT="$(skopeo inspect "docker://${REGISTRY_URL}/mirror/mongo:${APP_V}" --creds "$CREDS")"
DIGEST="$(printf '%s' "$INSPECT" | tr -d '\n' | sed -n 's/.*"Digest"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p')"
if [ -z "$DIGEST" ]; then
echo "failed to parse digest from skopeo inspect output" >&2
exit 1
fi
printf 'MONGO_TAG=%s\nMONGO_DIGEST=%s\n' "$APP_V" "$DIGEST" | tee .env.lock ci/prod/env/.env.lock.db
cat .env.lock