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
http://readme.drone.io/usage/skipping-build-steps
Consider this structure of the project that called ‘MyApp’
MyApp
.drone.yml
service1/
Dockerfile
service2/ # I want to trigger build only of this service only if commit modified files there
Dockerfile
service3/
Dockerfile
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 https://github.com/drone/drone/issues/1021
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.
pipeline:
prepare:
image: alpine:3.4
commands:
- export PHP_BASE_TAG=${PHP_BASE_TAG}
- ./prepare_build.sh
docker:
image: drone/plugin-docker
registry: docker.solutiondrive.de
username: ${DOCKER_USERNAME}
password: ${DOCKER_PASSWORD}
email: ${DOCKER_EMAIL}
repo: registry/library/php-xdebug
tags: ${DOCKER_TAGS}
file: Dockerfile
when:
branch: master
event: push
matrix:
include:
# 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
#!/bin/sh
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