1 Star 0 Fork 0

GitSharp/docker-gitlab

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
.gitlab-ci.yml 1.74 KB
一键复制 编辑 原始数据 按行查看 历史
image: docker:18-git
stages:
- build
before_script:
- export VERSION=$(cat VERSION)
- export CI_REGISTRY=${CI_REGISTRY:-hub.docker.com}
- export CI_REGISTRY_USER=${CI_REGISTRY_USER:-gitlab-ci-token}
- export CI_REGISTRY_PASSWORD=${CI_REGISTRY_PASSWORD:-${CI_JOB_TOKEN}}
- export DOCKER_IMAGE=${DOCKER_IMAGE:-${CI_REGISTRY}/${CI_PROJECT_PATH}}
- |
if [ "${DOCKER_IMAGE}" = "/" ]; then
export DOCKER_IMAGE=sameersbn/gitlab
fi
docker:build:
stage: build
only:
- master
script:
- docker login -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD} ${CI_REGISTRY}
- docker build
--pull
--cache-from=${DOCKER_IMAGE}
--build-arg=VCS_REF=$(git rev-parse --short HEAD)
--build-arg=BUILD_DATE="$(date +"%Y-%m-%d %H:%M:%S%:z")"
--tag ${DOCKER_IMAGE} .
- docker push ${DOCKER_IMAGE}
docker:build:branches:
stage: build
only:
- branches
except:
- master
script:
- docker login -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD} ${CI_REGISTRY}
- docker build
--pull
--cache-from=${DOCKER_IMAGE}:${CI_COMMIT_REF_SLUG}
--build-arg=VCS_REF=$(git rev-parse --short HEAD)
--build-arg=BUILD_DATE="$(date +"%Y-%m-%d %H:%M:%S%:z")"
--tag ${DOCKER_IMAGE}:${CI_COMMIT_REF_SLUG} .
- docker push ${DOCKER_IMAGE}:${CI_COMMIT_REF_SLUG}
docker:build:release:
stage: build
only:
- tags
script:
- docker login -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD} ${CI_REGISTRY}
- docker build
--pull
--cache-from=${DOCKER_IMAGE}:${VERSION}
--build-arg=VCS_REF=$(git rev-parse --short HEAD)
--build-arg=BUILD_DATE="$(date +"%Y-%m-%d %H:%M:%S%:z")"
--tag ${DOCKER_IMAGE}:${VERSION} .
- docker push ${DOCKER_IMAGE}:${VERSION}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/gitsharp/docker-gitlab.git
[email protected]:gitsharp/docker-gitlab.git
gitsharp
docker-gitlab
docker-gitlab
master

搜索帮助