Skip to content
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

story(issue-51): implement upload content api #56

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ jobs:

- name: Build Container Images
run: |
tarballTargets=$(bazel query "kind(filegroup, //...)" | grep ".tar$")
while IFS=';' read -ra tarballs; do
for tarball in "${tarballs[@]}"; do
bazel build $tarball
done
done <<< "$tarballTargets"
imageTargets=$(bazel query "kind(oci_image, //...)")
while IFS=';' read -ra targets; do
for target in "${targets[@]}"; do
bazel build $target
done
done <<< "$imageTargets"
18 changes: 5 additions & 13 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,9 @@ jobs:

- name: Build and publish images
run: |
tarballTargets=$(bazel query "kind(filegroup, //...)" | grep ".tar$")
while IFS=';' read -ra tarballs; do
for tarball in "${tarballs[@]}"; do
bazel build $tarball
tarFiles=$(bazel cquery --noshow_progress --ui_event_filters=-info,-stderr --output=files $tarball)
img=$(docker load -q --input $tarFiles)
imgWithTag=${img#"Loaded image: "}
imgAndTag=(${imgWithTag//:/ })
img=${imgAndTag[0]}
tag=${imgAndTag[1]}
docker tag $imgWithTag "$img:${{ github.event.release.tag_name }}"
docker push -a $img
pushTargets=$(bazel query "kind(oci_push, //...)")
while IFS=';' read -ra targets; do
for target in "${targets[@]}"; do
bazel run --stamp --embed_label ${{ github.event.release.tag_name }} $target
done
done <<< "$tarballTargets"
done <<< "$pushTargets"
14 changes: 10 additions & 4 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ use_repo(
"com_github_spf13_cobra",
"com_github_spf13_pflag",
"com_github_stretchr_testify",
"com_github_swaggest_openapi_go",
"com_github_z5labs_bedrock",
"com_github_z5labs_humus",
"io_opentelemetry_go_contrib_instrumentation_net_http_otelhttp",
Expand All @@ -40,12 +41,17 @@ use_repo(

oci = use_extension("@rules_oci//oci:extensions.bzl", "oci")
oci.pull(
name = "distroless_base",
digest = "sha256:ccaef5ee2f1850270d453fdf700a5392534f8d1a8ca2acda391fbb6a06b81c86",
image = "gcr.io/distroless/base",
name = "distroless_static",
digest = "sha256:cc226ca14d17d01d4b278d9489da930a0dd11150df10ae95829d13e6d00fbdbf",
image = "gcr.io/distroless/static",
platforms = [
"linux/amd64",
"linux/arm64",
],
)
use_repo(oci, "distroless_base", "distroless_base_linux_amd64", "distroless_base_linux_arm64")
use_repo(
oci,
"distroless_static",
"distroless_static_linux_amd64",
"distroless_static_linux_arm64",
)
38 changes: 19 additions & 19 deletions MODULE.bazel.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

60 changes: 60 additions & 0 deletions cmd/griot/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
load("@aspect_bazel_lib//lib:expand_template.bzl", "expand_template")
load("@rules_go//go:def.bzl", "go_binary", "go_library")
load("@rules_oci//oci:defs.bzl", "oci_image", "oci_load", "oci_push")
load("@rules_pkg//pkg:tar.bzl", "pkg_tar")

go_library(
name = "griot_lib",
Expand All @@ -15,5 +18,62 @@ go_library(
go_binary(
name = "griot",
embed = [":griot_lib"],
pure = "on",
static = "on",
visibility = ["//visibility:public"],
)

pkg_tar(
name = "tar",
srcs = [":griot"],
)

expand_template(
name = "labels",
out = "_stamped.labels.txt",
stamp_substitutions = {
"0.0.0": "{{BUILD_EMBED_LABEL}}",
"CREATED_TIMESTAMP": "{{BUILD_TIMESTAMP}}",
},
template = [
"org.opencontainers.image.created=CREATED_TIMESTAMP",
"org.opencontainers.image.source=https://github.com/z5labs/griot",
"org.opencontainers.image.version=0.0.0",
"org.opencontainers.image.licenses=Apache-2.0",
"org.opencontainers.image.base.name=gcr.io/distroless/static",
"org.opencontainers.image.base.digest=sha256:cc226ca14d17d01d4b278d9489da930a0dd11150df10ae95829d13e6d00fbdbf",
],
)

oci_image(
name = "image",
base = "@distroless_static",
entrypoint = ["/griot"],
labels = ":labels",
tars = [":tar"],
)

oci_load(
name = "load",
image = ":image",
repo_tags = ["ghcr.io/z5labs/griot/griot:latest"],
)

expand_template(
name = "remote_tags",
out = "_stamped.remote_tags.txt",
stamp_substitutions = {
"0.0.0": "{{BUILD_EMBED_LABEL}}",
},
template = [
"latest",
"0.0.0",
],
)

oci_push(
name = "push",
image = ":image",
remote_tags = ":remote_tags",
repository = "ghcr.io/z5labs/griot/griot",
)
7 changes: 3 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ require (
github.com/spf13/cobra v1.8.1
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.9.0
github.com/swaggest/openapi-go v0.2.54
github.com/z5labs/bedrock v0.12.2
github.com/z5labs/humus v0.3.0
github.com/z5labs/humus v0.4.0
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.56.0
go.opentelemetry.io/otel v1.31.0
go.opentelemetry.io/otel/metric v1.31.0
Expand All @@ -23,19 +24,17 @@ require (
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.23.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/swaggest/jsonschema-go v0.3.72 // indirect
github.com/swaggest/openapi-go v0.2.54 // indirect
github.com/swaggest/refl v1.3.0 // indirect
go.opentelemetry.io/contrib/bridges/otelslog v0.6.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.7.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.31.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.31.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.31.0 // indirect
go.opentelemetry.io/otel/exporters/stdout/stdoutlog v0.7.0 // indirect
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.31.0 // indirect
go.opentelemetry.io/otel/log v0.7.0 // indirect
go.opentelemetry.io/otel/sdk v1.31.0 // indirect
go.opentelemetry.io/otel/sdk/log v0.7.0 // indirect
Expand Down
Loading