Verified Commit 1b005231 authored by Frank Sauerburger's avatar Frank Sauerburger
Browse files

Add initial Dockerfile and CI jobs

parent 8859b2ce
Pipeline #2983 passed with stages
in 1 minute and 6 seconds
stages:
- build
- deploy
# Template for docker-in-docker jobs, requires special runner with 'dind' tag
.dind: &dind_template
image: docker:git
stage: build
tags:
- dind
services:
- name: docker:dind
alias: docker-in-docker
variables:
DOCKER_HOST: tcp://docker-in-docker:2375/
# For non-tagged commits, manually build the image with the commit hash
build:manual:
<<: *dind_template
when: manual
# Use ${CI_COMMIT_SHORT_SHA} if you want to use shortend commit hashs
script:
- echo "${CI_REGISTRY_PASSWORD}" | docker login -u ${CI_REGISTRY_USER} --password-stdin ${CI_REGISTRY}
- docker build -t ${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHA} .
- docker push ${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHA}
# For tagged commits, automatically build a tagged image.
build:tag:
<<: *dind_template
only: [tags]
script:
- echo "${CI_REGISTRY_PASSWORD}" | docker login -u ${CI_REGISTRY_USER} --password-stdin ${CI_REGISTRY}
- docker build -t ${CI_REGISTRY_IMAGE}:${CI_COMMIT_TAG} .
- docker push ${CI_REGISTRY_IMAGE}:${CI_COMMIT_TAG}
# For commits on the release branches, automatically tag the image with the
# release name
tag:release_branch:
<<: *dind_template
stage: deploy
only:
- /^release\/.*$/
environment:
name: $CI_COMMIT_REF_NAME
url: https://url/to/your/registry
script:
# Pull image with full version identifier
- export UNIQUE_TAG=$(git describe)
- echo "${CI_REGISTRY_PASSWORD}" | docker login -u ${CI_REGISTRY_USER} --password-stdin ${CI_REGISTRY}
- docker pull ${CI_REGISTRY_IMAGE}:${UNIQUE_TAG}
- docker tag ${CI_REGISTRY_IMAGE}:${UNIQUE_TAG} ${CI_REGISTRY_IMAGE}:${CI_COMMIT_REF_NAME#release/}
- docker push ${CI_REGISTRY_IMAGE}:${CI_COMMIT_REF_NAME#release/}
FROM alpine
CMD ["echo", "Hello World!"]
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