我不知道 Bazel 或它是如何工作的,但我必须解决这个问题,最终归结为 bazel 没有将某个目录复制到构建中。
我重构了代码,因此首先尝试从目录中读取某个键 (jwk) private-keys
。运行时总是找不到文件。我认为 bazel 没有将private-keys
目录(src
与build
.
Project/
|-- private-keys\
|-- src/
| |-- //other directories
| |-- index.ts
|
|-- package.json
|-- BUILD.bazel
有一个映射对象可以复制里面的目录,src
我尝试../private-keys
在那里使用但没有用。
以下是BUILD.bazel
外观
SOURCES = glob(
["src/**/*.ts"],
exclude = [
"src/**/*.spec.ts",
"src/__mocks__/**/*.ts",
],
)
mappings_dict = {
"api": "build/api",
....
}
ts_project(
name = "compile_ts",
srcs = SOURCES,
incremental = True,
out_dir = "build",
root_dir = "src",
tsc = "@npm//typescript/bin:tsc",
tsconfig = ":ts_config_build",
deps = DEPENDENCIES + TYPE_DEPENDENCIES,
)
ts_project(
name = "compile_ts",
srcs = SOURCES,
incremental = True,
out_dir = "build",
root_dir = "src",
tsc = "@npm//typescript/bin:tsc",
tsconfig = ":ts_config_build",
deps = DEPENDENCIES + TYPE_DEPENDENCIES,
)
_mappings = module_mappings(
name = "mappings",
mappings = mappings_dict,
)
# Application binary and docker imaage
nodejs_image(
name = "my-service",
data = [
":compile_ts",
"@npm//source-map-support",
] + _mappings,
entry_point = "build/index.js",
templated_args = [
"--node_options=--require=source-map-support/register",
"--bazel_patch_module_resolver",
],
)