GoogleContainerTools / GoogleContainerTools/skaffold

Add option for custom builder for Skaffold to push image

Open
#5,032 0 comments 0 reactions 0 assignees View on GitHub
area/build build/custom help wanted kind/feature-request priority/p2
Dominant language
Go
Stars
15.9k
Forks
1.7k
Avg merge
3d 9h
Merged PRs (30d)
10

Description

### Background
Certain external builders, such as [the Spring Boot image builder](https://docs.spring.io/spring-boot/docs/2.3.0.RELEASE/maven-plugin/reference/html/#goals-build-image), are difficult to integrate with Skaffold as they build to the local Docker daemon only, and pushing is left as a separate step to be done with a `docker push`.

As a result, users of such builders must define custom build scripts that usually have the form:
```shell
#!/bin/sh
set -e
cd "$BUILD_CONTEXT"
mvn -pl "$1" org.springframework.boot:spring-boot-maven-plugin:build-image
-Dspring-boot.build-image.imageName="$IMAGE" -DskipTests=true
if [ "$PUSH_IMAGE" = true ]; then
docker push "$IMAGE"
fi
```

This script must have execute permission. This is repetitive boilerplate. It's not portable between *nix and Windows systems (and we don't offer a mechanism to specify per-OS commands). It loses clarity as the builder definition is now elsewhere.

### Feature Request

Skaffold should offer the ability to auto-push these images.

I was thinking a flag to indicate whether a custom builder supports pushing images would be enough. Something like:
```
custom:
buildCommand: mvn -pl my/project org.springframework.boot:spring-boot-maven-plugin:build-image
-Dspring-boot.build-image.imageName=$IMAGE -DskipTests=true
supportsPush: false
```

That does presume that the only other option is to build to the local docker daemon. Perhaps it might be better to have something more explicit like:
```
custom:
buildCommand: ...
type: localDockerOnly
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.