我有一个spring boot with jib项目,其中构建的最新Docker映像获得了“最新”标签。现在我已经为我的angular项目创建了Dockerfile和管道定义,但是没有创建最新的标记。如何让最新的镜像自动更新,就像我的spring boot jib项目一样?
我的Dockerfile:
FROM nginx:latest
COPY dist/test-docker-angular-app/ /usr/share/nginx/html
COPY nginx.conf /etc/nginx/nginx.conf我的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"发布于 2020-12-27 21:24:18
这对我很有效:
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:
- masterhttps://stackoverflow.com/questions/65449886
复制相似问题