Transmode / gradle-docker

A Gradle plugin to build Docker images from the build script.
Apache License 2.0
647 stars 142 forks source link

How to pass docker build arguments to Dockerfile through gradle command line #154

Closed devopsadmin-james closed 4 years ago

devopsadmin-james commented 4 years ago

How to pass build arguments to one of a below gradleTask (Say dockertest) to below Dockerfile from gradle command line like "gradle dockertest -Pbimage=test.jar" is it possilbe like we pass through docker cli "docker build --build-args bimage=test.jar"

FROM openjdk:8-jre

VOLUME /tmp ARG bimage ADD $bimage java.jar

RUN bash -c 'touch /java.jar'

EXPOSE 8080

task dockertest(type: Docker, dependsOn: build) { push = false tag = 'test/java' tagVersion = "${ver}" dockerfile = file('src/main/docker/Dockerfile') buildArgs = "${bimage}" doFirst { copy { from "build/libs/'${image}'" into 'build/docker' } } }

devopsadmin-james commented 4 years ago

Use -P= to pass parameters to gradle tasks

anonymousshakespear commented 1 year ago

Use -P= to pass parameters to gradle tasks

could you help me to clarify it more? I still have no idea how to pass build args to dockerfile

In Dockerfile, I defined ARG Token In gradle task, I add -PToken but it didn't work

anonymousshakespear commented 1 year ago

ah, figured it out