stages:
  - build-image
  - deploy

build-2:
  stage: build-image
  image: docker:24
  services:
    - name: docker:24-dind
      command: ["--insecure-registry=38.47.185.86:8900"]

  variables:
    DOCKER_HOST: tcp://docker:2375
    DOCKER_TLS_CERTDIR: ""

  script:
    - docker version
    - docker login -u $DEPLOY_USERNAME -p $DEPLOY_TOKEN 38.47.185.86:8900
    - docker build -t registry.gitlab.com/hanifsalafi/web-qudo-be:dev .
    - docker tag registry.gitlab.com/hanifsalafi/web-qudo-be:dev 38.47.185.86:8900/medols/web-qudo-be:dev
    - docker push 38.47.185.86:8900/medols/web-qudo-be:dev

deploy:
  stage: deploy
  when: on_success
  image: curlimages/curl:latest
  script:
    - curl --user $JENKINS_USER:$JENKINS_PWD "http://38.47.185.86:8080/job/autodeploy-medols-be/build?token=autodeploymedols"
