stages:
  - build-image
  - deploy

build:
  stage: build-image
  image:
    name: docker:25.0.3-cli
  services:
    - name: docker:25.0.3-dind
      command: ["--insecure-registry=38.47.185.86:8900"]
  script:
    - docker login -u $DEPLOY_USERNAME -p $DEPLOY_TOKEN 38.47.185.86:8900
    - docker compose build
    - docker tag registry.gitlab.com/hanifsalafi/jaecoo-be:dev 38.47.185.86:8900/medols/jaecoo-be:dev
    - docker push 38.47.185.86:8900/medols/jaecoo-be:dev

deploy:
  stage: deploy
  when: on_success
  image: curlimages/curl:latest
  services:
    - docker:dind
  script:
    - curl --user $JENKINS_USER:$JENKINS_PWD "http://38.47.185.86:8080/job/autodeploy-jaecoo-be/build?token=autodeployjaecoo"
