.gitlab-ci.yml 805 Bytes
Newer Older
1 2 3 4 5 6 7
services:
- docker:dind

variables:
    DOCKER_HOST: tcp://localhost:2375
    DOCKER_DRIVER: overlay2

Mathieu Courcelles's avatar
Mathieu Courcelles committed
8
before_script:
9
    - echo "$CI_BUILD_TOKEN" | docker login -u gitlab-ci-token --password-stdin $CI_REGISTRY
Mathieu Courcelles's avatar
Mathieu Courcelles committed
10 11 12

build:
  script:
13
    - docker build  --cache-from $CI_REGISTRY_IMAGE:build --build-arg CI_COMMIT_SHA=$CI_COMMIT_SHA -t $CI_REGISTRY_IMAGE:build .
Mathieu Courcelles's avatar
Mathieu Courcelles committed
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
    - docker push $CI_REGISTRY_IMAGE:build
  stage: build


deploy:
  environment: production
  only:
    - master
  script:
    - export TODAY=$(date +"%Y.%m.%d")
    - docker pull $CI_REGISTRY_IMAGE:build
    - docker tag $CI_REGISTRY_IMAGE:build $CI_REGISTRY_IMAGE:latest
    - docker tag $CI_REGISTRY_IMAGE:build $CI_REGISTRY_IMAGE:$TODAY
    - docker push $CI_REGISTRY_IMAGE:latest
    - docker push $CI_REGISTRY_IMAGE:$TODAY
  stage: deploy