kind: pipeline
type: docker
name: default
steps:
  - name: container-build
    image: 'docker:dind'
    environment:
      USERNAME:
        from_secret: docker_username
      PASSWORD:
        from_secret: docker_password
    volumes:
      - name: dockersock
        path: /var/run/docker.sock
    commands:
      - >-
        if [ "${DRONE_BRANCH}" = "main" ]; then export
        BUILD_TAG="latest"; else export BUILD_TAG="${DRONE_BRANCH}"; fi;
      - docker login -u $USERNAME -p $PASSWORD git.argideli.com
      - >-
        docker build -t
        git.argideli.com/${DRONE_REPO_NAMESPACE}/${DRONE_REPO_NAME}:$BUILD_TAG
        .        
      - >-
        docker push
        git.argideli.com/${DRONE_REPO_NAMESPACE}/${DRONE_REPO_NAME}:$BUILD_TAG        
volumes:
  - name: dockersock
    host:
      path: /var/run/docker.sock