Docker 如何制作使用gitlab ci构建的最新映像;最新的;?
我有一个spring boot with jib项目,其中构建的最新Docker映像具有“最新”标签。现在我已经为我的angular项目创建了Dockerfile和管道定义,但是没有创建最新的标记。如何使最新的映像自动成为最新的,就像我的springbootjib项目一样 我的Dockerfile:Docker 如何制作使用gitlab ci构建的最新映像;最新的;?,docker,gitlab-ci,Docker,Gitlab Ci,我有一个spring boot with jib项目,其中构建的最新Docker映像具有“最新”标签。现在我已经为我的angular项目创建了Dockerfile和管道定义,但是没有创建最新的标记。如何使最新的映像自动成为最新的,就像我的springbootjib项目一样 我的Dockerfile: FROM nginx:latest COPY dist/test-docker-angular-app/ /usr/share/nginx/html COPY nginx.conf /etc/ngi
FROM nginx:latest
COPY dist/test-docker-angular-app/ /usr/share/nginx/html
COPY nginx.conf /etc/nginx/nginx.conf
My gitlab-ci.yml:
stages:
- build
- package
variables:
VERSION: ${CI_COMMIT_SHORT_SHA}-${CI_COMMIT_REF_SLUG}
build-prod-app:
stage: build
image: node:latest
script:
- npm install -g @angular/cli@9.1.0
- npm install
- ng build --prod
artifacts:
paths:
- dist/
expire_in: 2 hours
cache:
paths:
- node_modules/
docker-build:
image: docker:stable
stage: package
services:
- docker:dind
before_script:
- echo $CI_BUILD_TOKEN | docker login -u "$CI_REGISTRY_USER"
--password-stdin $CI_REGISTRY
script:
- IMAGE_NAME="$CI_REGISTRY_IMAGE:$VERSION"
- docker build --pull -t "$IMAGE_NAME" -f Dockerfile .
- docker push "$IMAGE_NAME"
这对我起了作用:
docker-build-master:
image: docker:stable
stage: package
services:
- docker:dind
before_script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
script:
- docker build --pull -t "$CI_REGISTRY_IMAGE" .
- docker push "$CI_REGISTRY_IMAGE"
only:
- master
docker-build:
image: docker:stable
stage: package
services:
- docker:dind
before_script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
script:
- IMAGE_NAME="$CI_REGISTRY_IMAGE:$VERSION"
- docker build --pull -t "$IMAGE_NAME" .
- docker push "$IMAGE_NAME"
except:
- master