Skip to content

Commit

Permalink
- split disk cache from cache
Browse files Browse the repository at this point in the history
  - move config into own package
  - implement remote read/write through
  - add YAML config file option

(way too many changes in one commit - sorry :\)
  • Loading branch information
buchgr committed Aug 20, 2018
1 parent 6064d3c commit 700d941
Show file tree
Hide file tree
Showing 26 changed files with 1,429 additions and 478 deletions.
9 changes: 7 additions & 2 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,13 @@ go_library(
visibility = ["//visibility:private"],
deps = [
"//cache:go_default_library",
"@com_github_abbot_go_http_auth//:go_default_library",
"@com_github_urfave_cli//:go_default_library",
"//cache/disk:go_default_library",
"//cache/gcs:go_default_library",
"//cache/http:go_default_library",
"//config:go_default_library",
"//server:go_default_library",
"//vendor/github.com/abbot/go-http-auth:go_default_library",
"//vendor/github.com/urfave/cli:go_default_library",
],
)

Expand Down
69 changes: 65 additions & 4 deletions Gopkg.lock

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

50 changes: 29 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ size and bazel-remote will automatically enforce this limit and clean the cache
last access time. The cache supports HTTP basic authentication with usernames and passwords being specified by a
`.htpasswd` file.

Cache entries are set and retrieved by key, and there are two types of key that can be used:
Cache entries are set and retrieved by key, and there are two types of keys that can be used:
1. Content addressed storage (CAS), where the key is the lowercase SHA256 hash of the stored value.
The REST API for these entries is: `/cas/<key>` or with an optional but ignored cache pool name: `/<pool>/cas/<key>`.
2. Action cache, where the key is an arbitrary 64 character lowercase hexadecimal string.
Expand All @@ -19,28 +19,36 @@ Values are stored via HTTP PUT requests, and retrieved via GET requests.
**Project status**: bazel-remote has been serving TBs of cache artifacts per day since April 2018, both on
commodity hardware and AWS servers. Outgoing bandwidth can exceed 15 Gbit/s on the right AWS instance type.

## Using bazel-remote
## Usage

The cache can be configured via command line flags, environment variables or a YAML configuration
file. See `./config/config_test.go` for the configuration format.

```
Usage of ./bazel-remote:
-dir string
Directory path where to store the cache contents. This flag is required.
-host string
Address to listen on. Listens on all network interfaces by default.
-htpasswd_file string
Path to a .htpasswd file. This flag is optional. Please read
https://httpd.apache.org/docs/2.4/programs/htpasswd.html.
-max_size int
The maximum size of the remote cache in GiB. This flag is required. (default -1)
-port int
The port the HTTP server listens on (default 8080)
-tls_cert_file string
Path to a PEM encoded certificate file. Required if tls_enabled is set to true.
-tls_enabled
Bool specifying whether or not to start the server with tls. If true, server_cert and server_key flags
are required.
-tls_key_file string
Path to a PEM encoded key file. Required if tls_enabled is set to true.
$ ./bazel-remote --help
NAME:
bazel-remote - A remote build cache for Bazel
USAGE:
bazel-remote [global options] command [command options] [arguments...]
DESCRIPTION:
A remote build cache for Bazel.
COMMANDS:
help, h Shows a list of commands or help for one command
GLOBAL OPTIONS:
--config_file value Path to a YAML configuration file. If this flag is specified then all other flags are ignored. [$BAZEL_REMOTE_CONFIG_FILE]
--dir value Directory path where to store the cache contents. This flag is required. [$BAZEL_REMOTE_DIR]
--max_size value The maximum size of the remote cache in GiB. This flag is required. (default: -1) [$BAZEL_REMOTE_MAX_SIZE]
--host value Address to listen on. Listens on all network interfaces by default. [$BAZEL_REMOTE_HOST]
--port value The port the HTTP server listens on. (default: 8080) [$BAZEL_REMOTE_PORT]
--htpasswd_file value Path to a .htpasswd file. This flag is optional. Please read https://httpd.apache.org/docs/2.4/programs/htpasswd.html. [$BAZEL_REMOTE_HTPASSWD_FILE]
--tls_enabled This flag has been deprecated. Specify tls_cert_file and tls_key_file instead. [$BAZEL_REMOTE_TLS_ENABLED]
--tls_cert_file value Path to a pem encoded certificate file. [$BAZEL_REMOTE_TLS_CERT_FILE]
--tls_key_file value Path to a pem encoded key file. [$BAZEL_REMOTE_TLS_KEY_FILE]
--help, -h show help
```

## Docker
Expand Down
46 changes: 44 additions & 2 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,54 @@ go_repository(

go_repository(
name = "org_golang_x_crypto",
commit = "5119cf507ed5294cc409c092980c7497ee5d6fd2",
commit = "ab813273cd59e1333f7ae7bff5d027d4aadf528c",
importpath = "golang.org/x/crypto",
)

go_repository(
name = "org_golang_x_net",
commit = "f5dfe339be1d06f81b22525fe34671ee7d2c8904",
commit = "1e491301e022f8f977054da4c2d852decd59571f",
importpath = "golang.org/x/net",
)

go_repository(
name = "com_github_golang_protobuf",
commit = "b4deda0973fb4c70b50d226b1af49f3da59f5265",
importpath = "github.com/golang/protobuf",
)

go_repository(
name = "com_google_cloud_go",
commit = "0fd7230b2a7505833d5f69b75cbd6c9582401479",
importpath = "cloud.google.com/go",
)

go_repository(
name = "in_gopkg_yaml_v2",
commit = "5420a8b6744d3b0345ab293f6fcba19c978f1183",
importpath = "gopkg.in/yaml.v2",
)

go_repository(
name = "org_golang_google_appengine",
commit = "150dc57a1b433e64154302bdc40b6bb8aefa313a",
importpath = "google.golang.org/appengine",
)

go_repository(
name = "org_golang_x_oauth2",
commit = "ec22f46f877b4505e0117eeaab541714644fdd28",
importpath = "golang.org/x/oauth2",
)

go_repository(
name = "com_github_urfave_cli",
commit = "cfb38830724cc34fedffe9a2a29fb54fa9169cd1",
importpath = "github.com/urfave/cli",
)

go_repository(
name = "com_github_google_go_cmp",
commit = "3af367b6b30c263d47e8895973edcca9a49cf029",
importpath = "github.com/google/go-cmp",
)
20 changes: 2 additions & 18 deletions cache/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,24 +1,8 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
load("@io_bazel_rules_go//go:def.bzl", "go_library")

go_library(
name = "go_default_library",
srcs = [
"cache.go",
"http.go",
"lru.go",
],
srcs = ["cache.go"],
importpath = "github.com/buchgr/bazel-remote/cache",
visibility = ["//visibility:public"],
deps = ["@com_github_djherbis_atime//:go_default_library"],
)

go_test(
name = "go_default_test",
srcs = [
"cache_test.go",
"http_test.go",
"lru_test.go",
"utils_test.go",
],
embed = [":go_default_library"],
)
Loading

0 comments on commit 700d941

Please sign in to comment.