Verified Commit 7147ff86 authored by tr's avatar tr
Browse files

Build docker image in GitLab CI

parent 94c6c0c8
---
stages:
- build
- test
- deploy
build:
stage: build
tags:
- dind
script:
- docker version
- docker build --no-cache -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME" .
- docker login -u gitlab-ci-token -p "$CI_JOB_TOKEN" "$CI_REGISTRY"
- docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME"
test:
stage: test
tags:
- docker
image:
name: "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME"
script:
- echo "Image $CI_REGISTRY_IMAGE $CI_COMMIT_REF_NAME"
- nginx -t 2>&1 | grep ModSecurity-nginx
- test -x /usr/local/bin/modsec-rules-check
deploy latest:
stage: deploy
tags:
- dind
rules:
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
script:
- docker version
- docker login -u gitlab-ci-token -p "$CI_JOB_TOKEN" "$CI_REGISTRY"
- docker pull "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME"
- docker tag "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME" "$CI_REGISTRY_IMAGE:latest"
- docker rmi "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME"
- docker push "$CI_REGISTRY_IMAGE:latest"
# vim: set ts=2 sw=2 :
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