{"id":26447624,"url":"https://github.com/abitofhelp/apis","last_synced_at":"2025-08-19T15:08:38.689Z","repository":{"id":214286994,"uuid":"732851469","full_name":"abitofhelp/apis","owner":"abitofhelp","description":"This repository contains an example using Go, Bazel 7 (bzlmod), ProtoBuf, grpc-gateway, GoogleApis, and gRPC.","archived":false,"fork":false,"pushed_at":"2024-01-12T01:39:08.000Z","size":222,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-18T02:40:16.781Z","etag":null,"topics":["bazel","bazel-example","go","golang","googleapis","grpc","grpc-gateway","grpc-go","http-proxy","protobuf","protocol-buffers"],"latest_commit_sha":null,"homepage":"","language":"Starlark","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/abitofhelp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-12-18T02:10:08.000Z","updated_at":"2024-01-09T05:54:02.000Z","dependencies_parsed_at":"2024-01-12T05:34:46.841Z","dependency_job_id":null,"html_url":"https://github.com/abitofhelp/apis","commit_stats":null,"previous_names":["abitofhelp/apis"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/abitofhelp/apis","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abitofhelp%2Fapis","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abitofhelp%2Fapis/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abitofhelp%2Fapis/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abitofhelp%2Fapis/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/abitofhelp","download_url":"https://codeload.github.com/abitofhelp/apis/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abitofhelp%2Fapis/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271173359,"owners_count":24711667,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-19T02:00:09.176Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bazel","bazel-example","go","golang","googleapis","grpc","grpc-gateway","grpc-go","http-proxy","protobuf","protocol-buffers"],"created_at":"2025-03-18T13:57:56.830Z","updated_at":"2025-08-19T15:08:38.646Z","avatar_url":"https://github.com/abitofhelp.png","language":"Starlark","readme":"# apis\n\nRecently, many exciting releases of key technologies used in microservice architectures have been released.\nUnfortunately, I couldn't find any examples online that use the latest releases of those technologies, so I have created\nthis sample, which works out the kinks I encountered. Although it is a simple project, it does present real-world\nrequirements and usage.\n\nThis system is composed of gRPC and HTTP proxy servers. You use the gRPC client or an HTTP client, such as curl or\nPostman, to interact with the servers.\n\n* Bazel (v7-bzlmod)\n* Go (1.21.5)\n* Protobuf (v21.7)\n* gRPC (v1.48.1)\n* gRPC-Gateway HTTP Proxy\n* GoogleApis\n\n## DEPENDENCY UPDATES\n\nFor Go-based projects, the go.mod file is the \"source of truth\" for dependencies in Bazel.\nThe latest version of rules_go eliminated the need to create and use a Gazelle rule, \"gazelle-update-repos\", to update\ndependencies in a Go application. After adding, updating, or removing a dependency in go.mod, do a 'go mod tidy' and\nverify that the application can be built by:\n\n```go build ./..```\n\nAfter you've verified that you can build the application using Go Build, there are a few steps to draw the changes into\nBazel.\n\n* If you've added or removed a DIRECT dependency from go.mod, then you need to amend the MODULE.bazel file. This file\n  has a use_repo() block, which contains entries for all DIRECT dependencies, so add or remove the dependency from the\n  block, as required.\n\n* After you've adjusted MODULE.bazel, you will use Gazelle to update dependencies for Bazel. I recommend committing to\n  git (local) prior to performing this step so you can easily identify any files that are changed and review the\n  changes. Gazelle will sometimes undo changes that I've made in BUILD.bazel files. Here is the command to use for this\n  step:\n\n```bazel run //:gazelle```\n\n## ISSUE\n\nOne of Bazel's core tenets is that it must be able to perform reproducible builds,\nso it builds in a hermetically sealed environment (\"sandbox\"), and the sources are immutable during a build.\nHence, during a build, the generated files cannot be copied to the sources involved.\n\nThis is an issue with a Go project because the module system will not locate the generated files in the sandbox,\nwhich results in missing dependency errors. This issue has been open for years, and there is no immediate solution\non the horizon, so most teams will use two distinct steps -- generate files and build the application.\n\n## CD/CD \u0026 LOCAL DEVELOPMENT PROCEDURE\n\nSo, the workaround is the following:\n\nCreate a file named .bazelignore in the proto/hello_world/v1 folder; its content is \"hello_world.pb.go\".\n\n1) Invoke Bazel on your generation target;\n2) Copy the generated file to a location in your sources; and\n3) Build your application;\n\nFor this project, the process is the following:\n\n1. ```\n   bazel build //proto/hello_world/v1:hello_world\n   ```\n\n\n2. Manually copy the generated files:\n   ```\n   from\n   \n   bazel-bin/proto/hello_world/v1/hello_world_pb/github.com/abitofhelp/apis/proto/hello_world/v1/proto/hello_world/v1/hello_world.pb.go\n   bazel-bin/proto/hello_world/v1/hello_world_pb/github.com/abitofhelp/apis/proto/hello_world/v1/proto/hello_world/v1/hello_world.pb.gw.go\n   bazel-bin/proto/hello_world/v1/hello_world_pb/github.com/abitofhelp/apis/proto/hello_world/v1/proto/hello_world/v1/hello_world_grpc.pb.go\n   \n   to\n   \n   proto/hello_world/v1/hello_world.pb.go\n   proto/hello_world/v1/hello_world.pb.gw.go\n   proto/hello_world/v1/hello_world_grpc.pb.go\n   \n   AND from\n   \n   bazel-bin/proto/enum/access_tier/v5/access_tier_pb/github.com/abitofhelp/apis/proto/enum/access_tier/v5/proto/enum/access_tier/v5/access_tier.pb.go\n   bazel-bin/proto/enum/access_tier/v5/access_tier_pb/github.com/abitofhelp/apis/proto/enum/access_tier/v5/proto/enum/access_tier/v5/access_tier.pb.gw.go\n   bazel-bin/proto/enum/access_tier/v5/access_tier_pb/github.com/abitofhelp/apis/proto/enum/access_tier/v5/proto/enum/access_tier/v5/access_tier_grpc.pb.go\n   \n   TO\n   \n   proto/enum/access_tier/v5/access_tier.pb.go\n   proto/enum/access_tier/v5/access_tier.pb.gw.go\n   proto/enum/access_tier/v5/access_tier_grpc.pb.go\n   ```\n\n3. ```\n   bazel build //...\n   ```\n\nTo test the build, use three separate terminal windows:\n\n```\n  # Start the gRPC server:\n  bazel run //server:server\n  \n  # Start the HTTP Proxy server:\n  bazel run //proxy:proxy\n  \n  # Use the gRPC client to send the request.\n  bazel run //client:client  \n  \n  # Use the HTTP client to send the request.\n  curl --location 'http://localhost:50052/v1/hello' \\\n    --header 'Content-Type: application/json' \\\n    --data '{\"name\": \"Mike\",\"sentUtc\": \"2024-01-03T01:33:31Z\"}'\n```\n\n## LOCAL DEVELOPMENT PROCESS IMPROVEMENT\n\nThe aforementioned is a procedure that can be used for CI/CD as well as local development. However, for local work, it\nmay be possible to avoid the two-step process and manual copying of generated files. If you use Visual Studio Code,\nthere is a plug-in available that integrates generated files into Go's builds without having to copy them. For Goland\ndevelopers, there is a Bazel plug-in that provides the same capability. Still, you have to use the following menu for\nGoland to configure the build of Bazel projects properly.\n**File -\u003e Import Bazel Project**\nAfter I imported this project, I did not have to copy generated files, so my development cycle was fast.\n\n## Please note that for CI/CD builds, I am unaware of any way to avoid the two-step process I've described.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabitofhelp%2Fapis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fabitofhelp%2Fapis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabitofhelp%2Fapis/lists"}