Skip to content
Snippets Groups Projects
.gitlab-ci.yml 3.01 KiB
image: docker:git

services:
  - docker:dind

stages:
  - sonar-analysis
  - build
  - deploy

build:
  image: docker:18.09
  services:
    - docker:18.09-dind
  stage: build
  only:
    - master
    - recette
  script:
    - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
    - docker build --pull -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" --build-arg conf=prod .
    - docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG"

build_dev:
  image: docker:18.09
  services:
    - docker:18.09-dind
  stage: build
  only:
    - dev
  script:
    - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
    - docker build --pull -t "$CI_REGISTRY_IMAGE:dev" --build-arg conf=dev .
    - docker push "$CI_REGISTRY_IMAGE:dev"

build_mobile:
  image: docker:18.09
  services:
    - docker:18.09-dind
  stage: build
  only:
    - mobile
  script:
    - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
    - docker build --pull -t "$CI_REGISTRY_IMAGE:mobile" --build-arg conf=dev .
    - docker push "$CI_REGISTRY_IMAGE:mobile"

build_json_server:
  image: docker:18.09
  services:
    - docker:18.09-dind
  stage: build
  only:
    - dev
  script:
    - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
    - docker build --pull -t "$CI_REGISTRY_IMAGE:json_server"  ./api/
    - docker push "$CI_REGISTRY_IMAGE:json_server"
  when: manual

deploy_dev:
  stage: deploy
  tags:
    - deploy
  only:
    - dev
  script:
    - cd /home/mps/ram
    - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
    - docker-compose pull web-app