-
Notifications
You must be signed in to change notification settings - Fork 0
/
BUILD.bazel
90 lines (77 loc) · 2.07 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
load("@npm//:defs.bzl", "npm_link_all_packages")
load("@aspect_rules_ts//ts:defs.bzl", "ts_config", "ts_project")
load("@aspect_bazel_lib//lib:copy_to_bin.bzl", "copy_to_bin")
load("@aspect_rules_swc//swc:defs.bzl", "swc")
load("@aspect_rules_js//js:defs.bzl", "js_binary")
load("@aspect_rules_js//npm:defs.bzl", "npm_link_package")
load("@bazel_skylib//lib:partial.bzl", "partial")
load("@io_bazel_rules_docker//container:container.bzl", "container_image")
load("@io_bazel_rules_docker//container:layer.bzl", "container_layer")
load("//:js_image_layer.bzl", "js_image_layer")
package(default_visibility = ["//visibility:public"])
npm_link_package(
name = "node_modules/@org/lib1",
src = "//lib1",
)
npm_link_package(
name = "node_modules/@org/lib2",
src = "//lib2",
)
npm_link_all_packages(name = "node_modules")
ts_config(
name = "tsconfig",
src = ":tsconfig.json",
)
copy_to_bin(
name = "swcrc",
srcs = [".swcrc"],
)
ts_project(
name = "app",
srcs = ["main.ts"],
composite = True,
declaration = True,
transpiler = partial.make(
swc,
swcrc = "//:swcrc",
),
tsconfig = "//:tsconfig",
deps = [
"//:node_modules/@org/lib1",
"//:node_modules/@types/node",
# Transitive dependencies need to be added to make them available
# in the `container_image`. But they are not necessary for `js_binary`
# "//:node_modules/@faker-js/faker",
# "//:node_modules/@org/lib2",
],
)
js_binary(
name = "bin",
data = [":app"],
entry_point = "main.js",
)
js_image_layer(
name = "layers",
binary = ":bin",
root = "/app",
)
container_layer(
name = "app_layer",
tars = [":layers/app.tar"],
)
container_layer(
name = "node_modules_layer",
tars = [":layers/node_modules.tar"],
)
container_image(
name = "image",
architecture = "amd64",
base = "@debian_amd64//image",
cmd = ["/app/bin.sh"],
entrypoint = ["bash"],
layers = [
":app_layer",
":node_modules_layer",
],
stamp = "@io_bazel_rules_docker//stamp:always",
)