Skip to content
Snippets Groups Projects
Commit b8dc8d0b authored by Andrey  ARISTOV's avatar Andrey ARISTOV
Browse files

Merge branch 'aaristov-feature-docker-CI' into 'main'

Update .gitlab-ci.yml - add docker build

See merge request !3
parents 1c69863e dbd64627
No related branches found
Tags v0.4
1 merge request!3Update .gitlab-ci.yml - add docker build
Pipeline #81920 passed
......@@ -12,6 +12,7 @@ image: python:3.8
# only cache local items.
variables:
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
CI_REGISTRY: "registry-gitlab.pasteur.fr"
# Pip's cache doesn't store the python packages
# https://pip.pypa.io/en/stable/reference/pip_install/#caching
......@@ -20,15 +21,46 @@ variables:
# them in a virtualenv and cache it as well.
cache:
paths:
- .cache/pip
# - .cache/pip
- .tox/.tox
stages:
- test
- build
test:
stage: test
script:
- pip install tox flake8 pytest
- tox
docker-build:
# Use the official docker image.
image: registry-gitlab.pasteur.fr/dsi-tools/docker-images/docker:latest
stage: build
services:
- registry-gitlab.pasteur.fr/dsi-tools/docker-images/docker:dind
before_script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
# Default branch leaves tag empty (= latest tag)
# All other branches are tagged with the escaped branch name (commit ref slug)
script:
- |
if [[ "$CI_COMMIT_BRANCH" == "$CI_DEFAULT_BRANCH" ]]; then
tag=""
echo "Running on default branch '$CI_DEFAULT_BRANCH': tag = 'latest'"
else
tag=":$CI_COMMIT_REF_SLUG"
echo "Running on branch '$CI_COMMIT_BRANCH': tag = $tag"
fi
- docker build --pull -t "$CI_REGISTRY_IMAGE${tag}" .
- docker push "$CI_REGISTRY_IMAGE${tag}"
# Run this job in a branch where a Dockerfile exists
rules:
- if: $CI_COMMIT_BRANCH
exists:
- Dockerfile
# pages:
# script:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment