Rework GitLab CI configuration, always build Docker image artifact
This artifact will be used as master-branch and release image, without building the image again
This commit is contained in:
parent
0806b8fd9d
commit
45024d3dc6
1 changed files with 51 additions and 18 deletions
|
@ -17,6 +17,7 @@ before_script:
|
||||||
- apt-get update
|
- apt-get update
|
||||||
- apt-get install -y google-chrome-stable fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst fonts-freefont-ttf libxss1 --no-install-recommends
|
- apt-get install -y google-chrome-stable fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst fonts-freefont-ttf libxss1 --no-install-recommends
|
||||||
|
|
||||||
|
# Build Send, run npm tests
|
||||||
test:
|
test:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
|
@ -24,48 +25,80 @@ test:
|
||||||
- npm run lint
|
- npm run lint
|
||||||
- npm test
|
- npm test
|
||||||
|
|
||||||
# Release Docker image artifact for easy testing
|
# Build Docker image, export Docker image artifact
|
||||||
artifact-docker:
|
artifact-docker:
|
||||||
stage: artifact
|
stage: artifact
|
||||||
image: docker:latest
|
image: docker:latest
|
||||||
|
needs: []
|
||||||
|
services:
|
||||||
|
- docker:dind
|
||||||
|
variables:
|
||||||
|
IMG_FILE: "send:git-$CI_COMMIT_SHA.tar"
|
||||||
|
IMG_NAME: "send:git-$CI_COMMIT_SHA"
|
||||||
|
before_script: []
|
||||||
|
script:
|
||||||
|
- docker build -t $IMG_NAME .
|
||||||
|
- docker image save -o $IMG_FILE $IMG_NAME
|
||||||
|
artifacts:
|
||||||
|
paths:
|
||||||
|
- $IMG_FILE
|
||||||
|
expire_in: 1 week
|
||||||
|
|
||||||
|
# Release public Docker image for the master branch
|
||||||
|
release-docker-master:
|
||||||
|
stage: release
|
||||||
|
image: docker:latest
|
||||||
|
dependencies:
|
||||||
|
- artifact-docker
|
||||||
services:
|
services:
|
||||||
- docker:dind
|
- docker:dind
|
||||||
only:
|
only:
|
||||||
- master
|
- master
|
||||||
|
variables:
|
||||||
|
IMG_IMPORT_FILE: "send:git-$CI_COMMIT_SHA.tar"
|
||||||
|
IMG_IMPORT_NAME: "send:git-$CI_COMMIT_SHA"
|
||||||
|
IMG_NAME: "registry.gitlab.com/timvisee/send:master-$CI_COMMIT_SHA"
|
||||||
before_script: []
|
before_script: []
|
||||||
script:
|
script:
|
||||||
- export IMG_NAME=registry.gitlab.com/timvisee/send:master-$CI_COMMIT_SHA
|
|
||||||
|
|
||||||
# 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, report image name
|
# Load existing, retag for new image images
|
||||||
- docker build -t $IMG_NAME .
|
- docker image load -i $IMG_IMPORT_FILE
|
||||||
- docker push $IMG_NAME
|
- docker tag $IMG_IMPORT_NAME $IMG_NAME
|
||||||
- 'echo Docker image artifact published, available as:'
|
|
||||||
- 'echo " docker pull $IMG_NAME"'
|
|
||||||
|
|
||||||
# Release public Docker image
|
# Publish tagged image
|
||||||
|
- docker push $IMG_NAME
|
||||||
|
|
||||||
|
- 'echo "Docker image artifact published, available as:" && echo " docker pull $IMG_NAME"'
|
||||||
|
|
||||||
|
# Release public Docker image for a version tag
|
||||||
release-docker:
|
release-docker:
|
||||||
stage: release
|
stage: release
|
||||||
image: docker:latest
|
image: docker:latest
|
||||||
|
dependencies:
|
||||||
|
- artifact-docker
|
||||||
services:
|
services:
|
||||||
- docker:dind
|
- docker:dind
|
||||||
only:
|
only:
|
||||||
- /^v(\d+\.)*\d+$/
|
- /^v(\d+\.)*\d+$/
|
||||||
|
variables:
|
||||||
|
IMG_IMPORT_FILE: "send:git-$CI_COMMIT_SHA.tar"
|
||||||
|
IMG_IMPORT_NAME: "send:git-$CI_COMMIT_SHA"
|
||||||
|
IMG_NAME: "registry.gitlab.com/timvisee/send:$CI_COMMIT_REF_NAME"
|
||||||
|
IMG_NAME_LATEST: "registry.gitlab.com/timvisee/send:latest"
|
||||||
before_script: []
|
before_script: []
|
||||||
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
|
# 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, report image name
|
# Load existing, retag for new image images
|
||||||
- docker build -t $IMG_NAME .
|
- docker image load -i $IMG_IMPORT_FILE
|
||||||
- docker tag $IMG_NAME $IMG_NAME_LATEST
|
- docker tag $IMG_IMPORT_NAME $IMG_NAME
|
||||||
|
- docker tag $IMG_IMPORT_NAME $IMG_NAME_LATEST
|
||||||
|
|
||||||
|
# Publish tagged image
|
||||||
- docker push $IMG_NAME
|
- docker push $IMG_NAME
|
||||||
- docker push $IMG_NAME_LATEST
|
- docker push $IMG_NAME_LATEST
|
||||||
- 'echo Docker image artifact published, available as:'
|
|
||||||
- 'echo " docker pull $IMG_NAME_LATEST"'
|
- 'echo "Docker image artifact published, available as:" && echo " docker pull $IMG_NAME_LATEST" && echo " docker pull $IMG_NAME"'
|
||||||
- 'echo " docker pull $IMG_NAME"'
|
|
||||||
|
|
Loading…
Reference in a new issue