kind: pipeline
type: docker
name: default

trigger:
  event:
    - push

steps:
  - name: deploy-db
    image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dockerproxy-clientdrone:latest
    environment:
      IMAGENAME: mariadb:10
      CONTAINERNAME: mysql
      COMMAND: create
      OVERWRITE: true
      #PRIVATE: true
      CODEFIRST_CLIENTDRONE_ENV_MARIADB_ROOT_PASSWORD:
        from_secret: db_root_password        
      CODEFIRST_CLIENTDRONE_ENV_MARIADB_DATABASE:
        from_secret: db_database
      CODEFIRST_CLIENTDRONE_ENV_MARIADB_USER:
        from_secret: db_user
      CODEFIRST_CLIENTDRONE_ENV_MARIADB_PASSWORD:
        from_secret: db_password
      ADMINS: dorianhodin,aurianjault,corentinrichard,remiarnal


  - name: create-image
    image: plugins/docker
    settings:
      dockerfile: ./Dockerfile
      context: .
      registry: hub.codefirst.iut.uca.fr
      repo: hub.codefirst.iut.uca.fr/dorian.hodin/fukashitapi
      username:
        from_secret: SECRET_USERNAME
      password:
        from_secret: SECRET_PASSWD

  - name: deploy-api
    image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dockerproxy-clientdrone:latest
    environment:
      IMAGENAME: hub.codefirst.iut.uca.fr/dorian.hodin/fukashitapi:latest
      CONTAINERNAME: fukashitapi
      COMMAND: create
      OVERWRITE: true
      ADMINS: dorianhodin,aurianjault,corentinrichard,remiarnal
    depends_on: [ create-image ]