-
Notifications
You must be signed in to change notification settings - Fork 159
/
BUILD.bazel
188 lines (169 loc) · 5.62 KB
/
BUILD.bazel
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
load("@gazelle//:def.bzl", "gazelle")
load("@io_bazel_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.bzl", "pkg_tar")
gazelle(
name = "gazelle",
prefix = "github.com/buchgr/bazel-remote/v2",
)
go_library(
name = "go_default_library",
srcs = ["main.go"],
importpath = "github.com/buchgr/bazel-remote/v2",
visibility = ["//visibility:private"],
deps = [
"//cache/disk:go_default_library",
"//config:go_default_library",
"//ldap:go_default_library",
"//server:go_default_library",
"//utils/flags:go_default_library",
"//utils/idle:go_default_library",
"//utils/rlimit:go_default_library",
"@com_github_abbot_go_http_auth//:go_default_library",
"@com_github_grpc_ecosystem_go_grpc_prometheus//:go_default_library",
"@com_github_prometheus_client_golang//prometheus/promhttp:go_default_library",
"@com_github_slok_go_http_metrics//metrics/prometheus:go_default_library",
"@com_github_slok_go_http_metrics//middleware:go_default_library",
"@com_github_slok_go_http_metrics//middleware/std:go_default_library",
"@com_github_urfave_cli_v2//:go_default_library",
"@org_golang_google_grpc//:go_default_library",
"@org_golang_google_grpc//credentials:go_default_library",
"@org_golang_x_sync//errgroup:go_default_library",
"@org_golang_x_sync//semaphore:go_default_library",
],
)
go_binary(
name = "bazel-remote",
cgo = True,
embed = [":go_default_library"],
pure = "off",
static = "off",
visibility = ["//visibility:public"],
x_defs = {"main.gitCommit": "{STABLE_GIT_COMMIT}"},
)
go_binary(
name = "bazel-remote-linux-amd64",
cgo = True,
embed = [":go_default_library"],
goarch = "amd64",
goos = "linux",
pure = "off",
static = "off",
visibility = ["//visibility:public"],
x_defs = {"main.gitCommit": "{STABLE_GIT_COMMIT}"},
)
go_binary(
name = "bazel-remote-linux-arm64",
cgo = True,
embed = [":go_default_library"],
goarch = "arm64",
goos = "linux",
pure = "off",
static = "on",
visibility = ["//visibility:public"],
x_defs = {"main.gitCommit": "{STABLE_GIT_COMMIT}"},
)
go_binary(
name = "bazel-remote-darwin-amd64",
cgo = True,
embed = [":go_default_library"],
goarch = "amd64",
goos = "darwin",
pure = "off",
#static = "on", # With static enabled, I get the following error: "ld: library not found for -lcrt0.o"
visibility = ["//visibility:public"],
x_defs = {"main.gitCommit": "{STABLE_GIT_COMMIT}"},
)
go_binary(
name = "bazel-remote-darwin-arm64",
cgo = True,
embed = [":go_default_library"],
goarch = "arm64",
goos = "darwin",
pure = "off",
#static = "on", # With static enabled, I get the following error: "ld: library not found for -lcrt0.o"
visibility = ["//visibility:public"],
x_defs = {"main.gitCommit": "{STABLE_GIT_COMMIT}"},
)
# The distroless static container image's nonroot user id.
BAZEL_REMOTE_USER_ID = 65532
pkg_tar(
name = "bazel-remote_tar",
srcs = [":bazel-remote"],
)
oci_image(
name = "bazel-remote-image",
base = "@cgo_amd64_base", # Does not include openssl.
entrypoint = [
"/bazel-remote",
"--http_address=:8080",
"--dir=/data",
# Listen on all addresses, not just 127.0.0.1, so this can
# be reached from outside the container (with a -p mapping).
# Specify a port to enable the profiling http server.
"--profile_address=:6060",
],
exposed_ports = ["8080"],
tars = [
"data.tar",
":bazel-remote_tar",
],
user = str(BAZEL_REMOTE_USER_ID),
visibility = ["//visibility:public"],
)
oci_load(
name = "bazel-remote-image-tarball",
image = ":bazel-remote-image",
repo_tags = ["buchgr/bazel-remote-cache:tmp-amd64"],
)
pkg_tar(
name = "bazel-remote-linux-arm64_tar",
srcs = [":bazel-remote-linux-arm64"],
)
oci_image(
name = "bazel-remote-image-arm64",
base = "@cgo_arm64_base", # Does not include openssl.
entrypoint = [
"/bazel-remote-linux-arm64",
"--http_address=:8080",
"--dir=/data",
# Listen on all addresses, not just 127.0.0.1, so this can
# be reached from outside the container (with a -p mapping).
# Specify a port to enable the profiling http server.
"--profile_address=:6060",
],
exposed_ports = ["8080"],
tars = [
"data.tar",
":bazel-remote-linux-arm64_tar",
],
user = str(BAZEL_REMOTE_USER_ID),
visibility = ["//visibility:private"],
)
oci_load(
name = "bazel-remote-image-arm64-tarball",
image = ":bazel-remote-image-arm64",
repo_tags = ["buchgr/bazel-remote-cache:tmp-arm64"],
)
# The following container_push targets push to "tmp-amd64" and "tmp-arm64"
# tags, so they can be combined into a multiarch tag on dockerhub. This
# isn't currently possible with rules_docker, so instead we rely on some
# external commands to be run after the tmp-* tags are pushed. See the
# docker/push_to_dockerhub script.
#
# Background:
# https://github.com/bazelbuild/rules_docker/issues/1599
oci_push(
name = "push_to_dockerhub_amd64",
image = ":bazel-remote-image",
remote_tags = ["tmp-amd64"],
repository = "buchgr/bazel-remote-cache",
visibility = ["//visibility:public"],
)
oci_push(
name = "push_to_dockerhub_arm64",
image = ":bazel-remote-image-arm64",
remote_tags = ["tmp-arm64"],
repository = "buchgr/bazel-remote-cache",
visibility = ["//visibility:public"],
)