-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Jib on Google Cloud Build #1478
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
apiVersion: skaffold/v1beta2 | ||
apiVersion: skaffold/v1beta3 | ||
kind: Config | ||
build: | ||
artifacts: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
apiVersion: skaffold/v1beta2 | ||
apiVersion: skaffold/v1beta3 | ||
kind: Config | ||
build: | ||
artifacts: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
apiVersion: skaffold/v1beta2 | ||
apiVersion: skaffold/v1beta3 | ||
kind: Config | ||
build: | ||
tagPolicy: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
apiVersion: skaffold/v1beta2 | ||
apiVersion: skaffold/v1beta3 | ||
kind: Config | ||
build: | ||
artifacts: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,12 @@ | ||
apiVersion: skaffold/v1beta2 | ||
apiVersion: skaffold/v1beta3 | ||
kind: Config | ||
build: | ||
artifacts: | ||
- image: gcr.io/k8s-skaffold/skaffold-jib | ||
jibMaven: {} | ||
|
||
# optional profile to run the jib build on Google Cloud Build | ||
profiles: | ||
- name: gcb | ||
build: | ||
googleCloudBuild: {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
apiVersion: skaffold/v1beta2 | ||
apiVersion: skaffold/v1beta3 | ||
kind: Config | ||
build: | ||
artifacts: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
apiVersion: skaffold/v1beta2 | ||
apiVersion: skaffold/v1beta3 | ||
kind: Config | ||
build: | ||
artifacts: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
apiVersion: skaffold/v1beta2 | ||
apiVersion: skaffold/v1beta3 | ||
kind: Config | ||
deploy: | ||
kustomize: {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
apiVersion: skaffold/v1beta2 | ||
apiVersion: skaffold/v1beta3 | ||
kind: Config | ||
build: | ||
artifacts: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
apiVersion: skaffold/v1beta2 | ||
apiVersion: skaffold/v1beta3 | ||
kind: Config | ||
build: | ||
artifacts: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
apiVersion: skaffold/v1beta2 | ||
apiVersion: skaffold/v1beta3 | ||
kind: Config | ||
build: | ||
artifacts: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
apiVersion: skaffold/v1beta2 | ||
apiVersion: skaffold/v1beta3 | ||
kind: Config | ||
build: | ||
artifacts: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
apiVersion: skaffold/v1beta2 | ||
apiVersion: skaffold/v1beta3 | ||
kind: Config | ||
build: | ||
artifacts: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
Copyright 2018 The Skaffold Authors | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package gcb | ||
|
||
import ( | ||
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/jib" | ||
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest" | ||
cloudbuild "google.golang.org/api/cloudbuild/v1" | ||
) | ||
|
||
// TODO(dgageot): check that `package` is bound to `jib:build` | ||
func (b *Builder) jibMavenBuildSteps(imageName string, artifact *latest.JibMavenArtifact) []*cloudbuild.BuildStep { | ||
return []*cloudbuild.BuildStep{{ | ||
Name: b.MavenImage, | ||
Args: jib.GenerateMavenArgs("dockerBuild", imageName, artifact), | ||
}} | ||
} | ||
|
||
func (b *Builder) jibGradleBuildSteps(imageName string, artifact *latest.JibGradleArtifact) []*cloudbuild.BuildStep { | ||
return []*cloudbuild.BuildStep{{ | ||
Name: b.GradleImage, | ||
Args: jib.GenerateGradleArgs("jibDockerBuild", imageName, artifact), | ||
}} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
Copyright 2018 The Skaffold Authors | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package gcb | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest" | ||
"github.com/GoogleContainerTools/skaffold/testutil" | ||
cloudbuild "google.golang.org/api/cloudbuild/v1" | ||
) | ||
|
||
func TestJibMavenBuildSteps(t *testing.T) { | ||
artifact := &latest.JibMavenArtifact{} | ||
|
||
builder := Builder{ | ||
GoogleCloudBuild: &latest.GoogleCloudBuild{ | ||
MavenImage: "maven:3.6.0", | ||
}, | ||
} | ||
steps := builder.jibMavenBuildSteps("img", artifact) | ||
|
||
expected := []*cloudbuild.BuildStep{{ | ||
Name: "maven:3.6.0", | ||
Args: []string{"--non-recursive", "prepare-package", "jib:dockerBuild", "-Dimage=img"}, | ||
}} | ||
|
||
testutil.CheckDeepEqual(t, expected, steps) | ||
} | ||
|
||
func TestJibGradleBuildSteps(t *testing.T) { | ||
artifact := &latest.JibGradleArtifact{} | ||
|
||
builder := Builder{ | ||
GoogleCloudBuild: &latest.GoogleCloudBuild{ | ||
GradleImage: "gradle:5.1.1", | ||
}, | ||
} | ||
steps := builder.jibGradleBuildSteps("img", artifact) | ||
|
||
expected := []*cloudbuild.BuildStep{{ | ||
Name: "gradle:5.1.1", | ||
Args: []string{":jibDockerBuild", "--image=img"}, | ||
}} | ||
|
||
testutil.CheckDeepEqual(t, expected, steps) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,6 +59,8 @@ const ( | |
UpdateCheckEnvironmentVariable = "SKAFFOLD_UPDATE_CHECK" | ||
|
||
DefaultCloudBuildDockerImage = "gcr.io/cloud-builders/docker" | ||
DefaultCloudBuildMavenImage = "gcr.io/cloud-builders/mvn" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. WDYT about using the gcr.io/k8s-skaffold/skaffold image for every builder? Then we wouldn't have to use multiple images There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Copy the context + skaffold.yaml, then invoke There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know about that. I have a few questions:
|
||
DefaultCloudBuildGradleImage = "gcr.io/cloud-builders/gradle" | ||
|
||
// A regex matching valid repository names (https://github.com/docker/distribution/blob/master/reference/reference.go) | ||
RepositoryComponentRegex string = `^[a-z\d]+(?:(?:[_.]|__|-+)[a-z\d]+)*$` | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this still TODO or can it be removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is still a TODO that might or might not be important