gradle-docker
gradle-docker copied to clipboard
generateDockerCompose should allow filtering of content for replacing token
Like with a copySpec, the generateDockerCompose
task should offer an option to filter content.
copySpec.from (dockerSourceDir, {
include '*.yml'
filter(ReplaceTokens, tokens: [name: project.name, version: project.version as String, image: docker.name])
})
What's the use case for this?
project.name
and docker.name
should probably be stable names that don't or very rarely change. The generateDockerCompose
task already supports replacing version names from the docker configuration dependencies.
Well, project.name and version have been chosen just as an example. We are using a generic docker-compose.yml template and need to replace various variable values that com from the project setup, and that varies. In our case it is not sufficient to just replace the version numbers of dependent containers.
Could you give some examples of what values you are trying to replace?
I think generating docker-compose files from very generic templates is outside the scope of this plugin. If you need that behavior you can define a custom copy task to do the token replacement.
I'm doing environment variables for example where for certain configurations are determined by Gradle. Technically, I'm not seeing the big difference to why that can be done with the Dockerfile but not the docker-compose file. It seems to be odd to have multiple places that need to manipulate a single file.