GoogleContainerTools/skaffold

Add option for custom builder for Skaffold to push image

Aperta

#5032 aperta il 17 nov 2020

 (0 commenti) (0 reazioni) (0 assegnatari)Go (1416 fork)batch import
area/buildbuild/customhelp wantedkind/feature-requestpriority/p2

Metriche repository

Star
 (12.822 stelle)
Metriche merge PR
 (Merge medio 3g 6h) (16 PR mergiate in 30 g)

Descrizione

Background

Certain external builders, such as the Spring Boot image builder, 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:

#!/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

Guida contributor