ci: build and release webdrop-api and webdrop-files as separate images [CI]
- dev images are built only when the push touched code that image uses (path filters); webdrop-files does not wait for the frontend build - one v* tag releases both images (:tag and :latest) after the shared checks - registry build and push live in scripts/ci-publish-image.sh, used by every workflow - containers: fix the api Containerfile (missing Sync project), add Containerfile.files, Quadlet units for the file service (prod and dev), env examples, and registry auto-update for the production units so each machine pulls only the image it runs
This commit is contained in:
1 parent
5489407241
commit
8af4f284a0
13 files changed
+279
-71
No files matched your search
@@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env bash
|
||||
# 构建并推送一个镜像到 registry。开发镜像和发布镜像、主后端和文件服务都用它,构建和推送的细节只写在这里。
|
||||
# 用法: ci-publish-image.sh <镜像名> <Containerfile> <版本标签> [额外标签...]
|
||||
# 例: ci-publish-image.sh webdrop-api server/Containerfile dev-abc1234 dev
|
||||
# 需要环境变量: ZOT_REGISTRY、ZOT_USERNAME、ZOT_SECRET(Woodpecker 的密钥)
|
||||
set -euo pipefail
|
||||
|
||||
name="$1"; containerfile="$2"; version="$3"; shift 3
|
||||
: "${ZOT_REGISTRY:?}" "${ZOT_USERNAME:?}" "${ZOT_SECRET:?}"
|
||||
: "${WOODPECKER_BACKEND_LOCAL_TEMP_DIR:=$HOME/woodpecker/work}"
|
||||
|
||||
# 每个镜像一个构建缓存目录,两个镜像并行构建时互不干扰
|
||||
store="$(dirname "$WOODPECKER_BACKEND_LOCAL_TEMP_DIR")/buildah-cache/$name"
|
||||
mkdir -p "$store/storage" "$store/run"
|
||||
buildah() { command buildah --root "$store/storage" --runroot "$store/run" "$@"; }
|
||||
|
||||
printf '%s' "$ZOT_SECRET" | buildah login --tls-verify=true --username "$ZOT_USERNAME" --password-stdin "$ZOT_REGISTRY"
|
||||
trap 'buildah logout "$ZOT_REGISTRY" >/dev/null 2>&1 || true' EXIT
|
||||
|
||||
commit="${CI_COMMIT_SHA:-$(git rev-parse HEAD)}"
|
||||
image="$ZOT_REGISTRY/justme/$name:$version"
|
||||
buildah bud --layers --network host --format oci --platform linux/amd64 \
|
||||
--build-arg "WEBDROP_FRONTEND_COMMIT=$commit" --build-arg "WEBDROP_FRONTEND_TAG=$version" \
|
||||
--build-arg "WEBDROP_BACKEND_COMMIT=$commit" --build-arg "WEBDROP_BACKEND_TAG=$version" \
|
||||
--build-arg "WEBDROP_BUILD_TIME=$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
|
||||
--tag "$image" --file "$containerfile" .
|
||||
|
||||
buildah push "$image" "docker://$image"
|
||||
for extra in "$@"; do
|
||||
buildah tag "$image" "$ZOT_REGISTRY/justme/$name:$extra"
|
||||
buildah push "$ZOT_REGISTRY/justme/$name:$extra" "docker://$ZOT_REGISTRY/justme/$name:$extra"
|
||||
done
|
||||
Reference in new issue
Block a user