Closed vickyleu closed 1 year ago
envs.env and gradle.properties are duplicated, there is no need to maintain two places
If you don't want to manually set the environments, you can even set the prefabricated prefix in gradle.properties, such as compose_service_name_key=value, and the environments are directly changed to the specified gradle.properties file, and all uncommented properties of gradle.properties are read in the code.
val lines = file(filePath). readLines()
for ((index, line) in lines. withIndex())
// Ignore lines that start with '#' (after trimming leading whitespace)
if (line. trimStart(). startsWith("#")) {continue}
// Ignore lines that not start with 'compose_'
if (!line. trimStart(). startsWith("compose_")) {continue}
it.environment(entry.key.replace("compose_", ""), entry.value)
gradle.properties
compose_app_image_name=abcdefg
compose_ppa_image_name=dfjdsfjsdf
services:
app:
image: ${app_image_name}
ports:
- ${app_port}:8080
ppa:
image: ${ppa_image_name}
ports:
- ${ppa_port}:8080
due to the lack of maintenance on the current issue, it has been closed. The solution can be found in the comments.
What happened?
dockerCompose only have dockerComposeFile or Template configure,but i want adding docker compose environment for docker-compose.yml
dockerCompose { setDockerComposeFile("docker-compose.yaml") }
What did you want to happen?
so i can use
now i can use gradle.propeties