Release Docker image for each version tag

This commit is contained in:
timvisee 2020-10-15 19:54:03 +02:00
parent 9e5da3270c
commit 175040acec
No known key found for this signature in database
GPG Key ID: B8DB720BC383E172

View File

@ -2,7 +2,8 @@ image: "node:12-slim"
stages: stages:
- test - test
- package - artifact
- release
before_script: before_script:
# Install dependencies # Install dependencies
@ -23,8 +24,9 @@ test:
- npm run lint - npm run lint
- npm test - npm test
package-docker: # Release Docker image artifact for easy testing
stage: package artifact-docker:
stage: artifact
image: docker:latest image: docker:latest
services: services:
- docker:dind - docker:dind
@ -37,6 +39,33 @@ package-docker:
# Login in to registry # Login in to registry
- 'docker login registry.gitlab.com -u $DOCKER_USER -p $DOCKER_PASS' - 'docker login registry.gitlab.com -u $DOCKER_USER -p $DOCKER_PASS'
# build and push image # Build and push image, report image name
- docker build -t $IMG_NAME . - docker build -t $IMG_NAME .
- docker push $IMG_NAME - docker push $IMG_NAME
- 'echo Docker image artifact published, available as:'
- 'echo " docker pull $IMG_NAME"'
# Release public Docker image
release-docker:
stage: release
image: docker:latest
services:
- docker:dind
only:
- /^v(\d+\.)*\d+$/
before_script: []
script:
- export IMG_NAME=registry.gitlab.com/timvisee/send:$CI_COMMIT_REF_NAME
- export IMG_NAME_LATEST=registry.gitlab.com/timvisee/send:latest
# Login in to registry
- 'docker login registry.gitlab.com -u $DOCKER_USER -p $DOCKER_PASS'
# Build and push image, report image name
- docker build -t $IMG_NAME .
- docker tag $IMG_NAME $IMG_NAME_LATEST
- docker push $IMG_NAME
- docker push $IMG_NAME_LATEST
- 'echo Docker image artifact published, available as:'
- 'echo " docker pull $IMG_NAME_LATEST"'
- 'echo " docker pull $IMG_NAME"'