Skip to content

Commit

Permalink
add goreleaser; bazel
Browse files Browse the repository at this point in the history
  • Loading branch information
salrashid123 committed Mar 29, 2024
1 parent 86ab781 commit 732547c
Show file tree
Hide file tree
Showing 8 changed files with 1,224 additions and 34 deletions.
97 changes: 97 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
project_name: grpc_health_proxy
release:
draft: true
github:
owner: salrashid123
name: grpc_health_proxy
name_template: '{{.Tag}}'
extra_files:

scoop:
name: grpc_health_proxy
commit_author:
name: sal
email: [email protected]
commit_msg_template: Scoop update for {{ .ProjectName }} version {{ .Tag }}
goamd64: v1
builds:
- id: grpc_health_proxy
goos:
- freebsd
- windows
- linux
- darwin
goarch:
- amd64
- '386'
- arm
- arm64
ignore:
- goos: darwin
goarch: '386'
goamd64:
- v1
goarm:
- 7
env:
- CGO_ENABLED=0
binary: grpc_health_proxy
builder: go
gobinary: go
command: build
ldflags:
- -s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{.Date}} -X main.builtBy=goreleaser
archives:
- id: archive
name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ with .Arm }}v{{ . }}{{ end }}{{ with .Mips }}_{{ . }}{{ end }}{{ if not (eq .Amd64 "v1") }}{{ .Amd64 }}{{ end }}'
format: binary
files:
- LICENSE*
- README*
- dist/*.sig
snapshot:
name_template: '{{ .Version }}-SNAPSHOT-{{ .ShortCommit }}'
checksum:
name_template: '{{ .ProjectName }}_{{ .Version }}_checksums.txt'
algorithm: sha256
dist: dist
signs:
- cmd: gpg
id: gpg
artifacts: all
output: true
args:
- "--batch"
- "--local-user"
- "{{ .Env.GPG_FINGERPRINT }}" # "5D8EA7261718FE5728BA937C97341836616BF511" [email protected] https://keyserver.ubuntu.com/pks/lookup?search=5D8EA7261718FE5728BA937C97341836616BF511&fingerprint=on&op=index
- "--output"
- "${signature}"
- "--detach-sign"
- "${artifact}"

env_files:
github_token: ~/.config/goreleaser/github_token
source:
name_template: '{{ .ProjectName }}-{{ .Version }}'
format: tar.gz
gomod:
gobinary: go
github_urls:
download: https://github.com

# creates SBOMs of all archives and the source tarball using syft
# https://goreleaser.com/customization/sbom
sboms:
- id: default
cmd: syft
env:
- SYFT_FILE_METADATA_CATALOGER_ENABLED=true
args:
- $artifact
- --file
- $document
- --output
- spdx-json
documents:
- ${artifact}.spdx.sbom
artifacts: archive
78 changes: 78 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
load("@rules_pkg//:pkg.bzl", "pkg_tar")
load("@rules_oci//oci:defs.bzl", "oci_image", "oci_push", "oci_tarball", "oci_image_index")
load("@bazel_gazelle//:def.bzl", "gazelle")

gazelle(name = "gazelle")

go_binary(
name = "main",
out = "grpc_health_proxy",
embed = [":cmd_lib"],
visibility = ["//visibility:public"],
goos = "linux",
goarch = "amd64",
)

go_library(
name = "cmd_lib",
srcs = [
"main.go",
],
visibility = ["//visibility:private"],
deps = [
"@com_github_golang_glog//:go_default_library",
"@org_golang_google_grpc//:go_default_library",
"@org_golang_google_grpc//codes:go_default_library",
"@org_golang_google_grpc//credentials:go_default_library",
"@org_golang_google_grpc//health/grpc_health_v1:go_default_library",
"@org_golang_google_grpc//status:go_default_library",
"@org_golang_x_net//http2:go_default_library",
],
)

pkg_tar(
name = "app-tar",
srcs = [":main"],
package_dir = "/",
)

oci_image(
name = "server-image",
base = "@distroless_base",
tars = [":app-tar"],
entrypoint = ["/grpc_health_proxy"],
cmd = [],
env = {},
exposed_ports = [
"8080/tcp",
],
)

oci_tarball(
name = "tar-docker",
image = "server-image",
format = "docker",
repo_tags = ["index.docker.io/salrashid123/grpc_health_proxy"],
)

oci_image_index(
name = "app-index",
images = [
":server-image",
]
)

oci_tarball(
name = "tar-oci-index",
image = ":app-index",
format = "oci",
repo_tags = ["index.docker.io/salrashid123/grpc_health_proxy"],
)

oci_push(
name = "push-image",
image = ":server-image",
repository = "index.docker.io/salrashid123/grpc_health_proxy",
remote_tags = ["latest"]
)
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.15 AS build
FROM golang:1.20 AS build
ENV PROJECT grpc_health_proxy
WORKDIR /src/$PROJECT
COPY go.mod go.sum ./
Expand Down
Loading

0 comments on commit 732547c

Please sign in to comment.