我有一个使用 git-crypt 加密文件的仓库。我已将密钥导出到文件中。现在我在 gitlab 上使用默认的 docker 镜像构建模板来构建我的镜像。管道工作得很好。我只是不知道如何在构建期间“解锁”文件,以便图像具有明文文件供使用。管道构建如下所示:
docker-build:
# Use the official docker image.
image: docker:latest
stage: build
services:
- docker:dind
before_script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
# Default branch leaves tag empty (= latest tag)
# All other branches are tagged with the escaped branch name (commit ref slug)
script:
- |
if [[ "$CI_COMMIT_BRANCH" == "$CI_DEFAULT_BRANCH" ]]; then
tag=""
echo "Running on default branch '$CI_DEFAULT_BRANCH': tag = 'latest'"
else
tag=":$CI_COMMIT_REF_SLUG"
echo "Running on branch '$CI_COMMIT_BRANCH': tag = $tag"
fi
echo $CI_REGISTRY_IMAGE${tag}
- docker build --pull -t "$CI_REGISTRY_IMAGE${tag}" .
- docker push "$CI_REGISTRY_IMAGE${tag}"
# Run this job in a branch where a Dockerfile exists
rules:
- if: $CI_COMMIT_BRANCH
exists:
- Dockerfile
我只是不确定解锁发生的地点或时间。它是否发生在 Dockerfile 或此构建过程中?我用谷歌搜索过,并认为这是一个常见的问题,但到目前为止还没有。
提前感谢您提供的任何帮助或链接。
布拉德