私は Bazel に比較的慣れていませんが、必要以上に時間がかかりました。私はyarn_install
自分のワークスペースでやっています。インストールされているものを参照しnode_modules
て、新しいdockerコンテナーに入れることができるようにしています。
ワークスペース
yarn_install(
name = "npm",
package_json = "//:package.json",
yarn_lock = "//:yarn.lock",
)
BUILD.bazel
load("@io_bazel_rules_docker//nodejs:image.bzl", "nodejs_image")
nodejs_image(
name = "webapi_image",
# gets all the files in my directory
data = glob(
[
"**/*",
],
# references the node modules, but doesn't work :(
) + ["@npm//node_modules"],
entry_point = "//:app.js",
)
特定のパッケージ (つまり@npm//express
) を取得できましたが、node_modules にアクセスしようとすると、
no such package '@npm//node_modules': Package is considered deleted due to --deleted_packages and referenced by '//:webapi_image'