.gitlab-ci.yml 1.12 KB
Newer Older
1 2 3 4 5 6 7 8 9
image: docker:latest

stages:
  - build
  - deploy

build:
  stage: build
  script:
Antoine Roux's avatar
Antoine Roux committed
10 11 12 13 14
    - docker login -u "$DOCKER_USER" -p "$DOCKER_PASS" "$DOCKER_REGISTRY"
    - docker build --pull -t "$DOCKER_REGISTRY/$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" .
    - docker image tag "$DOCKER_REGISTRY/$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" "$DOCKER_REGISTRY/$CI_REGISTRY_IMAGE:latest"
    - docker push "$DOCKER_REGISTRY/$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG"
    - docker push "$DOCKER_REGISTRY/$CI_REGISTRY_IMAGE:latest"
15 16 17 18 19 20
  except:
    - master

deploy_production:
  stage: deploy
  script:
Antoine Roux's avatar
Antoine Roux committed
21
    - docker login -u "$DOCKER_USER" -p "$DOCKER_PASS" "$DOCKER_REGISTRY"
22 23 24 25 26 27
    - export http_proxy=http://proxy.esrf.fr:3128
    - 'which ssh-agent || ( apk update && apk add openssh-client )'
    - eval $(ssh-agent -s)
    - echo "$SSH_DEPLOY_KEY_PROD" | ssh-add -
    - mkdir -p ~/.ssh
    - echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
Antoine Roux's avatar
Antoine Roux committed
28
    - ssh -l gitlab-deploy "$DEPLOY_HOST" "$DOCKER_REGISTRY/$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG"
29 30 31 32 33 34
  environment:
    name: production
    url: http://doi.esrf.fr/
  when: manual
  except:
    - master