Skip to content

Commit

Permalink
Add cache to prebuild (#4)
Browse files Browse the repository at this point in the history
* Add a cache build step to container build

* Add postcreate

* Changing lifecycle hook to prebuild cache
  • Loading branch information
BillyAutrey authored Oct 13, 2023
1 parent 13df421 commit 46381cd
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 25 deletions.
69 changes: 69 additions & 0 deletions .devcontainer/build-caches.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/bin/bash

# generate java BUILD file
cat > java/src/main/java/bazel/bootcamp/BUILD <<EOF
java_binary(
name = "HelloBazelBootcamp",
srcs = ["HelloBazelBootcamp.java"],
)
java_library(
name = "JavaLoggingClientLibrary",
srcs = ["JavaLoggingClientLibrary.java"],
deps = [
"//proto/logger:logger_java_proto",
"//proto/logger:logger_java_grpc",
"@io_grpc_grpc_java//core",
"@io_grpc_grpc_java//netty",
]
)
java_binary(
name = "JavaLoggingClient",
srcs = ["JavaLoggingClient.java"],
deps = [":JavaLoggingClientLibrary"],
visibility = ["//visibility:public"]
)
java_test(
name = "JavaLoggingClientLibraryTest",
srcs = ["JavaLoggingClientLibraryTest.java"],
deps = [":JavaLoggingClientLibrary"]
)
java_test(
name = "JavaLoggingClientTest",
srcs = ["JavaLoggingClientTest.java"],
deps = [":JavaLoggingClient"]
)
EOF


# generate proto BUILD file
cat > proto/logger/BUILD <<EOF
package(default_visibility = ["//visibility:public"])
load("@io_grpc_grpc_java//:java_grpc_library.bzl", "java_grpc_library")
proto_library(
name = "logger_proto",
srcs = ["logger.proto"]
)
java_proto_library(
name = "logger_java_proto",
deps = [":logger_proto"]
)
java_grpc_library(
name = "logger_java_grpc",
srcs = [":logger_proto"],
deps = [":logger_java_proto"],
)
EOF

bazel run //:gazelle
bazel build //...
git reset --hard
git clean -f
3 changes: 2 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
"ghcr.io/balazs23/devcontainers-features/bazel:1.0.1": {
"bazelisk": "v1.15.0"
}
}
},
"onCreateCommand": "bash .devcontainer/build-caches.sh"
}
24 changes: 0 additions & 24 deletions generate_build_files.sh
Original file line number Diff line number Diff line change
Expand Up @@ -79,30 +79,6 @@ sh_test(
)
EOF


cat > typescript/BUILD <<EOF
# FIXME(alexeagle)
# load("@npm_bazel_typescript//:index.bzl", "ts_library", "ts_devserver")
# ts_devserver(
# name = "devserver",
# bootstrap = ["@npm_bazel_typescript//:protobufjs_bootstrap_scripts"],
# entry_module = "bootcamp/typescript/app",
# port = 8088,
# deps = [":app"],
# )
# ts_library(
# name = "app",
# srcs = ["app.ts"],
# deps = [
# "//proto/logger:logger_ts_proto",
# ],
# )
# exports_files(["tsconfig.json"])
EOF

# write WORKSPACE file
${SHELL} ./generate_workspace.sh

Expand Down

0 comments on commit 46381cd

Please sign in to comment.