Commit 97b84c38 authored by Daniel Scholl's avatar Daniel Scholl
Browse files

Added pipline

parent 3cfe7b7a
# This is a GitLab CI configuration to build the project as a docker image
image: docker:19.03
include:
- template: Container-Scanning.gitlab-ci.yml
stages:
- build
- test
- push
before_script:
- echo -n $CI_JOB_TOKEN | docker login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY
# Docker Build, Tag and Push SHA
Build:
stage: build
tags: ['docker-runner']
script:
# fetches the latest image (not failing if image is not found)
- docker pull $CI_REGISTRY_IMAGE:latest || true
- >
docker build
--pull
--build-arg VCS_REF=$CI_COMMIT_SHA
--build-arg VCS_URL=$CI_PROJECT_URL
--build-arg BUILD_DATE=$CI_PIPELINE_CREATED_AT
--cache-from $CI_REGISTRY_IMAGE:latest
--tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
.
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
# Docker Pull SHA, Tag Latest and Push Latest
Push latest:
variables:
GIT_STRATEGY: none
stage: push
tags: ['docker-runner']
rules:
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
script:
- docker pull $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
- docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA $CI_REGISTRY_IMAGE:latest
- docker push $CI_REGISTRY_IMAGE:latest
# Docker Pull SHA, Tag and Push Tag
Push tag:
variables:
GIT_STRATEGY: none
stage: push
tags: ['docker-runner']
rules:
- if: $CI_COMMIT_TAG
script:
- docker pull $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
- docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME
container_scanning:
stage: test
before_script:
- ''
variables:
GIT_STRATEGY: fetch
DOCKER_IMAGE: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment