使用kaniko构建docker镜像
# 说明
1. 国内网络不建议使用kaniko构建(https://blog.51cto.com/zhangxueliang/5073004)
1
# 配置文件
build-job:
stage: build
image:
name: changingai/kaniko-executor
entrypoint: [ "" ]
before_script:
- export IMAGE_TAG="registry.cn-beijing.aliyuncs.com/xxx/spider:$CI_COMMIT_SHORT_SHA"
script:
- mkdir -p /kaniko/.docker
- echo "{\"auths\":{\"${CI_REGISTRY}\":{\"auth\":\"$(printf "%s:%s" "${CI_REGISTRY_USER}" "${CI_REGISTRY_PASSWORD}" | base64 | tr -d '\n')\"},\"registry.cn-beijing.aliyuncs.com\":{\"auth\":\"$(printf "%s:%s" username@qq.com password | base64 | tr -d '\n')\"}}}" > /kaniko/.docker/config.json
- /kaniko/executor --context "${CI_PROJECT_DIR}" --dockerfile "${CI_PROJECT_DIR}/Dockerfile" --destination "${IMAGE_TAG}" --build-arg "CI_JOB_TOKEN=${CI_JOB_TOKEN}"
- echo "Docker Push Success, IMAGE_TAG :${IMAGE_TAG}"
1
2
3
4
5
6
7
8
9
10
11
12
2
3
4
5
6
7
8
9
10
11
12
# 参考
上次更新: 2023-07-31 10:01:32