...
 
Commits (7)
stages:
- build
- test
- release
variables:
IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME
CONTAINER_TEST_IMAGE: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME
CONTAINER_RELEASE_IMAGE: $CI_REGISTRY_IMAGE:latest
CONTAINER_ID: '$CI_JOB_NAME-$CI_PROJECT_NAME-Pipeline$CI_PIPELINE_ID-Job$CI_JOB_ID'
before_script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
build:
tags:
- docker
- docker-builder
stage: build
script:
- docker build -t $IMAGE_TAG .
- docker push $IMAGE_TAG
\ No newline at end of file
- docker build --pull -t $CONTAINER_TEST_IMAGE .
- docker push $CONTAINER_TEST_IMAGE
test:
tags:
- docker-tester
stage: test
script:
- docker pull $CONTAINER_TEST_IMAGE
# Test running the container.
- docker run --name $CONTAINER_ID -d --privileged -v /sys/fs/cgroup:/sys/fs/cgroup:ro $CONTAINER_TEST_IMAGE /lib/systemd/systemd
# Verify Ansible is available in the container.
- docker exec --tty $CONTAINER_ID env TERM=xterm ansible --version
# Remove test-container
- docker rm -f $CONTAINER_ID
release-image:
tags:
- docker-builder
stage: release
script:
- docker pull $CONTAINER_TEST_IMAGE
- docker tag $CONTAINER_TEST_IMAGE $CONTAINER_RELEASE_IMAGE
- docker push $CONTAINER_RELEASE_IMAGE
only:
- master