Trigger build step based on modified directory

Hi everyone
Is it any way to skip build step based on which directories were changed by commit?

I can’t find anything related here

Consider this structure of the project that called ‘MyApp’

  service2/         # I want to trigger build only of this service only if commit modified files there

It would be extremely useful for projects with Monorepository which has multiple services with Dockerfiles in it. So we could build only images with modified code instead of useless rebuilding of already up-to-date ones.

this is not currently possible. There is an open issue for this, however, the full set of requirements and scope are not yet well defined and could use help

Hey there,

I had a similar requirement the past days - we need to build custom php docker images for our unit tests (which require some additional modules). I solved it by using the build matrix and building a Dockerfile when required for the step.

    image: alpine:3.4
      - export PHP_BASE_TAG=${PHP_BASE_TAG}
      - ./

    image: drone/plugin-docker
    username: ${DOCKER_USERNAME}
    password: ${DOCKER_PASSWORD}
    email: ${DOCKER_EMAIL}
    repo: registry/library/php-xdebug
    tags: ${DOCKER_TAGS}
    file: Dockerfile
      branch: master
      event: push

    # php 7.1 series
    - PHP_BASE_TAG: 7.1.4-alpine
      DOCKER_TAGS: 7.1, 7.1.4
      # 7.0 series
    - PHP_BASE_TAG: 7.0.18-alpine
      DOCKER_TAGS: 7.0, 7.0.18
echo "FROM php:${PHP_BASE_TAG}" > Dockerfile
cat Dockerfile.template >> Dockerfile

I realize it is not as convenient as watching a file - but it works and in our case it`s already useful.

If you need it on a file watch basis - you could easily write a docker plugin that does this for you. Iterare through the files in your repository - if the file is called Dockerfile , make a hash of it’s contents - store the hash “somewhere” and on the next run compare the hash with the stored one

Thanks we’ll try it!