-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: change bazel example * chore: update bazel example * chore: remove redundant dirs * chore: change example project schema version
- Loading branch information
1 parent
c4af00e
commit f2323ea
Showing
24 changed files
with
208 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
common --enable_bzlmod |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
6.1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules | ||
bazel-* |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
load("@aspect_bazel_lib//lib:transitions.bzl", "platform_transition_filegroup") | ||
load("@rules_go//go:def.bzl", "go_binary", "go_library") | ||
load("@rules_oci//oci:defs.bzl", "oci_image", "oci_tarball") | ||
load("@rules_pkg//:pkg.bzl", "pkg_tar") | ||
|
||
go_library( | ||
name = "app_lib", | ||
srcs = ["main.go"], | ||
importpath = "example.com/custom_registry/app", | ||
visibility = ["//visibility:private"], | ||
) | ||
|
||
go_binary( | ||
name = "app", | ||
embed = [":app_lib"], | ||
visibility = ["//visibility:public"], | ||
) | ||
|
||
# Put app go_binary into a tar layer. | ||
pkg_tar( | ||
name = "app_layer", | ||
srcs = [":app"], | ||
# If the binary depends on RUNFILES, uncomment the attribute below. | ||
# include_runfiles = True | ||
) | ||
|
||
oci_image( | ||
name = "image", | ||
base = "@distroless_base", | ||
entrypoint = ["/app"], | ||
tars = [":app_layer"], | ||
) | ||
|
||
# This is the target that should be released to the target platform | ||
platform_transition_filegroup( | ||
name = "transitioned_image", | ||
srcs = [":image"], | ||
target_platform = select({ | ||
"@platforms//cpu:arm64": "@rules_go//go/toolchain:linux_arm64", | ||
"@platforms//cpu:x86_64": "@rules_go//go/toolchain:linux_amd64", | ||
}), | ||
) | ||
|
||
# $ bazel build :tarball | ||
# $ docker load --input $(bazel cquery --output=files :tarball) | ||
# $ docker run --rm gcr.io/example:latest | ||
|
||
oci_tarball( | ||
name = "skaffold-example.tar", | ||
# Use the image built for the exec platform rather than the target platform | ||
image = ":image", | ||
repo_tags = ["gcr.io/example:latest"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
bazel_dep(name = "aspect_bazel_lib", version = "1.31.1") | ||
bazel_dep(name = "gazelle", version = "0.31.0") | ||
bazel_dep(name = "platforms", version = "0.0.5") | ||
bazel_dep(name = "rules_oci", version = "1.2.0") | ||
bazel_dep(name = "rules_pkg", version = "0.8.1") | ||
bazel_dep(name = "rules_go", version = "0.39.1") | ||
|
||
go_deps = use_extension("@gazelle//:extensions.bzl", "go_deps") | ||
|
||
go_deps.module( | ||
path = "github.com/google/go-cmp", | ||
sum = "h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=", | ||
version = "v0.5.9", | ||
) | ||
|
||
oci = use_extension("@rules_oci//oci:extensions.bzl", "oci") | ||
|
||
oci.pull( | ||
name = "distroless_base", | ||
digest = "sha256:ccaef5ee2f1850270d453fdf700a5392534f8d1a8ca2acda391fbb6a06b81c86", | ||
image = "gcr.io/distroless/base", | ||
platforms = [ | ||
"linux/amd64", | ||
"linux/arm64", | ||
], | ||
) | ||
|
||
use_repo(oci, "distroless_base") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Marker file: this is the root of a Bazel workspace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,5 +4,5 @@ metadata: | |
name: bazel | ||
spec: | ||
containers: | ||
- name: bazel | ||
image: skaffold-bazel | ||
- name: bazel | ||
image: skaffold-bazel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,16 @@ | ||
apiVersion: skaffold/v4beta8 | ||
kind: Config | ||
metadata: | ||
name: hello | ||
build: | ||
tagPolicy: | ||
sha256: {} | ||
artifacts: | ||
- image: skaffold-bazel | ||
bazel: | ||
target: //:skaffold_example.tar | ||
- image: skaffold-bazel | ||
bazel: | ||
target: //:skaffold-example.tar | ||
deploy: | ||
kubectl: {} | ||
manifests: | ||
rawYaml: | ||
- "deploy.yaml" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
common --enable_bzlmod |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
6.1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules | ||
bazel-* |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
load("@aspect_bazel_lib//lib:transitions.bzl", "platform_transition_filegroup") | ||
load("@rules_go//go:def.bzl", "go_binary", "go_library") | ||
load("@rules_oci//oci:defs.bzl", "oci_image", "oci_tarball") | ||
load("@rules_pkg//:pkg.bzl", "pkg_tar") | ||
|
||
go_library( | ||
name = "app_lib", | ||
srcs = ["main.go"], | ||
importpath = "example.com/custom_registry/app", | ||
visibility = ["//visibility:private"], | ||
) | ||
|
||
go_binary( | ||
name = "app", | ||
embed = [":app_lib"], | ||
visibility = ["//visibility:public"], | ||
) | ||
|
||
# Put app go_binary into a tar layer. | ||
pkg_tar( | ||
name = "app_layer", | ||
srcs = [":app"], | ||
# If the binary depends on RUNFILES, uncomment the attribute below. | ||
# include_runfiles = True | ||
) | ||
|
||
oci_image( | ||
name = "image", | ||
base = "@distroless_base", | ||
entrypoint = ["/app"], | ||
tars = [":app_layer"], | ||
) | ||
|
||
# This is the target that should be released to the target platform | ||
platform_transition_filegroup( | ||
name = "transitioned_image", | ||
srcs = [":image"], | ||
target_platform = select({ | ||
"@platforms//cpu:arm64": "@rules_go//go/toolchain:linux_arm64", | ||
"@platforms//cpu:x86_64": "@rules_go//go/toolchain:linux_amd64", | ||
}), | ||
) | ||
|
||
# $ bazel build :tarball | ||
# $ docker load --input $(bazel cquery --output=files :tarball) | ||
# $ docker run --rm gcr.io/example:latest | ||
|
||
oci_tarball( | ||
name = "skaffold-example.tar", | ||
# Use the image built for the exec platform rather than the target platform | ||
image = ":image", | ||
repo_tags = ["gcr.io/example:latest"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
bazel_dep(name = "aspect_bazel_lib", version = "1.31.1") | ||
bazel_dep(name = "gazelle", version = "0.31.0") | ||
bazel_dep(name = "platforms", version = "0.0.5") | ||
bazel_dep(name = "rules_oci", version = "1.2.0") | ||
bazel_dep(name = "rules_pkg", version = "0.8.1") | ||
bazel_dep(name = "rules_go", version = "0.39.1") | ||
|
||
go_deps = use_extension("@gazelle//:extensions.bzl", "go_deps") | ||
|
||
go_deps.module( | ||
path = "github.com/google/go-cmp", | ||
sum = "h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=", | ||
version = "v0.5.9", | ||
) | ||
|
||
oci = use_extension("@rules_oci//oci:extensions.bzl", "oci") | ||
|
||
oci.pull( | ||
name = "distroless_base", | ||
digest = "sha256:ccaef5ee2f1850270d453fdf700a5392534f8d1a8ca2acda391fbb6a06b81c86", | ||
image = "gcr.io/distroless/base", | ||
platforms = [ | ||
"linux/amd64", | ||
"linux/arm64", | ||
], | ||
) | ||
|
||
use_repo(oci, "distroless_base") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Marker file: this is the root of a Bazel workspace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,5 +4,5 @@ metadata: | |
name: bazel | ||
spec: | ||
containers: | ||
- name: bazel | ||
image: skaffold-bazel | ||
- name: bazel | ||
image: skaffold-bazel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.