gradle-docker icon indicating copy to clipboard operation
gradle-docker copied to clipboard

generateDockerCompose should allow filtering of content for replacing token

Open MartinAhrer opened this issue 7 years ago • 4 comments

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])
})

MartinAhrer avatar Nov 30 '17 11:11 MartinAhrer

What's the use case for this?

project.name and docker.nameshould probably be stable names that don't or very rarely change. The generateDockerCompose task already supports replacing version names from the docker configuration dependencies.

pkoenig10 avatar Mar 25 '18 02:03 pkoenig10

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.

MartinAhrer avatar Mar 25 '18 10:03 MartinAhrer

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.

pkoenig10 avatar Mar 25 '18 15:03 pkoenig10

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.

MartinAhrer avatar Mar 25 '18 16:03 MartinAhrer