Skip to content

Commit ae5a679

Browse files
authored
add --push flag to buildx (#571)
1 parent ade8ef3 commit ae5a679

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

readme.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ build/
6868
- `builder` (optional) a string argument which defines which builder buildx should use; defaults to `null`
6969
- `load` (optional) a boolean argument which defines whether Docker buildx builder should add --load flag,
7070
loading the image into the local repository; defaults to `false`
71+
- `push` (optional) a boolean argument which defines whether Docker buildx builder should add --push flag,
72+
pushing the image into the remote registry; defaults to `false`
7173

7274
To build a docker container, run the `docker` task. To push that container to a
7375
docker repository, run the `dockerPush` task.

src/main/groovy/com/palantir/gradle/docker/DockerExtension.groovy

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class DockerExtension {
4545
private boolean buildx = false
4646
private Set<String> platform = ImmutableSet.of()
4747
private boolean load = false
48+
private boolean push = false
4849
private String builder = null
4950

5051
private File resolvedDockerfile = null
@@ -188,6 +189,14 @@ class DockerExtension {
188189
this.pull = pull
189190
}
190191

192+
public boolean getPush() {
193+
return push
194+
}
195+
196+
public void push(boolean push) {
197+
this.push = push
198+
}
199+
191200
boolean getBuildx() {
192201
return buildx
193202
}

src/main/groovy/com/palantir/gradle/docker/PalantirDockerPlugin.groovy

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,12 @@ class PalantirDockerPlugin implements Plugin<Project> {
181181
if (ext.load) {
182182
buildCommandLine.add '--load'
183183
}
184+
if (ext.push) {
185+
buildCommandLine.add '--push'
186+
if (ext.load) {
187+
throw new Exception("cannot combine 'push' and 'load' options")
188+
}
189+
}
184190
if (ext.builder != null) {
185191
buildCommandLine.addAll('--builder', ext.builder)
186192
}

0 commit comments

Comments
 (0)