GoogleContainerTools/skaffold

Add option for custom builder for Skaffold to push image

开放

#5,032 创建于 2020年11月17日

 (0 条评论) (0 个反应) (0 位负责人)Go (1,416 个派生)batch import
area/buildbuild/customhelp wantedkind/feature-requestpriority/p2

仓库指标

星标
 (12,822 个星标)
PR 合并指标
 (平均合并 3天 6小时) (30 天内合并 16 个 PR)

描述

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

贡献者指南