-
Notifications
You must be signed in to change notification settings - Fork 0
/
BUILD.bazel
121 lines (107 loc) · 2.64 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
load("@npm//apps/team-bm/bm-testhub-frontend:@remix-run/dev/package_json.bzl", remix_dev = "bin")
load("@npm//apps/team-bm/bm-testhub-frontend:@remix-run/serve/package_json.bzl", remix_serve = "bin")
load("@aspect_rules_js//js:defs.bzl", "js_image_layer", "js_run_devserver")
load("@npm//:defs.bzl", "npm_link_all_packages")
load("//build-tools/shifter2:shifter_build_2.bzl", "stamped_container_image")
load("//build-tools:app_info.bzl", "app_name")
npm_link_all_packages()
DEPS = [
":node_modules/react",
":node_modules/react-dom",
":node_modules/@remix-run/serve",
":node_modules/@remix-run/node",
":node_modules/@remix-run/react",
":node_modules/@remix-run/web-fetch",
"jokul-tokens.ts",
"tailwind.config.ts",
":node_modules/isbot",
":node_modules/tailwindcss",
"//apps/team-bm/bm-testhub-frontend/app",
"tsconfig.json",
"package.json",
"remix.config.js",
]
DEV_DEPS = [
":node_modules/@remix-run/dev",
"remix.env.d.ts",
]
remix_dev.remix_binary(name = "remix_bin")
remix_dev.remix(
name = "app",
srcs = glob([
"public/**",
]) + DEV_DEPS + DEPS,
args = ["build"],
chdir = package_name(),
out_dirs = [
"build",
],
tags = [
"app",
"no-sandbox",
],
)
js_run_devserver(
name = "dev",
args = [
"dev --manual",
],
chdir = package_name(),
data = glob(
[
"public/**",
".env",
],
allow_empty = True,
) + DEPS + DEV_DEPS,
tool = ":remix_bin",
)
remix_serve.remix_serve_binary(
name = "start",
args = [
"build/index.js",
],
chdir = package_name(),
data = DEPS + [
":app",
] + glob(
[
"public/**",
".env",
],
allow_empty = True,
),
)
platform(
name = "linux_amd64",
constraint_values = [
"@platforms//os:linux",
"@platforms//cpu:x86_64",
],
)
js_image_layer(
name = "app_layer",
binary = ":start",
platform = ":linux_amd64",
root = "/app",
tags = ["manual"],
)
target_name = "start"
path_to_start = "/app/" + package_name() + "/" + target_name
path_to_runfiles = path_to_start + ".runfiles/_main"
path_to_package_root = path_to_runfiles + "/" + package_name()
stamped_container_image(
name = app_name(),
base_image = "@ubi9_minimal",
# js_image_layer root + package + / + name of binary
cmd = [
path_to_start,
"{}/build/index.js".format(path_to_package_root),
],
entrypoint = ["bash"],
image_layers = [
":app_layer",
],
image_name = app_name(),
workdir = path_to_runfiles,
)