Skip to content

Commit 6170dc5

Browse files
committed
minimal posix system shell
add dash (debian almquist shell) to docker images via deb package adjusted entrypoint to use a script that functions like the official upstream application image/container
1 parent 92128a5 commit 6170dc5

File tree

5 files changed

+164
-74
lines changed

5 files changed

+164
-74
lines changed

Diff for: BUILD

Whitespace-only changes.

Diff for: WORKSPACE

+80-12
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,26 @@ load("//tools/cpp:cc_repo_config.bzl", "cc_repo_config")
2525

2626
cc_repo_config(name = "local_config_arm_compiler")
2727

28-
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
28+
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive", "http_file")
2929

3030
# project rules
3131

32+
# deb_package
33+
# https://github.com/bazelbuild/rules_pkg
34+
http_archive(
35+
name = "deb_package",
36+
sha256 = "08ce92b9aea59ce6d592404de6cdfd7100c1140cdf4d4b9266942c20ec998b27",
37+
strip_prefix = "rules_pkg-0.2.4/deb_packages",
38+
urls = ["https://github.com/bazelbuild/rules_pkg/archive/0.2.4.tar.gz"],
39+
)
40+
3241
# rules_docker
3342
# https://github.com/bazelbuild/rules_docker
3443
http_archive(
3544
name = "io_bazel_rules_docker",
36-
sha256 = "e513c0ac6534810eb7a14bf025a0f159726753f97f74ab7863c650d26e01d677",
37-
strip_prefix = "rules_docker-0.9.0",
38-
urls = ["https://github.com/bazelbuild/rules_docker/archive/v0.9.0.tar.gz"],
45+
sha256 = "14ac30773fdb393ddec90e158c9ec7ebb3f8a4fd533ec2abbfd8789ad81a284b",
46+
strip_prefix = "rules_docker-0.12.1",
47+
urls = ["https://github.com/bazelbuild/rules_docker/releases/download/v0.12.1/rules_docker-v0.12.1.tar.gz"],
3948
)
4049

4150
load("@io_bazel_rules_docker//repositories:repositories.bzl", container_repos = "repositories")
@@ -58,7 +67,6 @@ http_archive(
5867
sha256 = "750186951a699cb73d6b440c7cd06f4b2b80fd3ebb00cbe00f655c7da4ae243e",
5968
strip_prefix = "tensorflow-590d6eef7e91a6a7392c8ffffb7b58f2e0c8bc6b",
6069
urls = [
61-
"https://mirror.bazel.build/github.com/tensorflow/tensorflow/archive/590d6eef7e91a6a7392c8ffffb7b58f2e0c8bc6b.tar.gz",
6270
"https://github.com/tensorflow/tensorflow/archive/590d6eef7e91a6a7392c8ffffb7b58f2e0c8bc6b.tar.gz",
6371
],
6472
)
@@ -69,7 +77,6 @@ http_archive(
6977
sha256 = "ddce3b3a3909f99b28b25071c40b7fec7e2e1d1d1a4b2e933f3082aa99517105",
7078
strip_prefix = "rules_closure-316e6133888bfc39fb860a4f1a31cfcbae485aef",
7179
urls = [
72-
"https://mirror.bazel.build/github.com/bazelbuild/rules_closure/archive/316e6133888bfc39fb860a4f1a31cfcbae485aef.tar.gz",
7380
"https://github.com/bazelbuild/rules_closure/archive/316e6133888bfc39fb860a4f1a31cfcbae485aef.tar.gz",
7481
],
7582
)
@@ -119,6 +126,67 @@ load("@tf_serving//tensorflow_serving:workspace.bzl", "tf_serving_workspace")
119126

120127
tf_serving_workspace()
121128

129+
# debian packages
130+
131+
load("@deb_package//:deb_packages.bzl", "deb_packages")
132+
133+
http_file(
134+
name = "buster_archive_key",
135+
sha256 = "9c854992fc6c423efe8622c3c326a66e73268995ecbe8f685129063206a18043",
136+
urls = ["https://ftp-master.debian.org/keys/archive-key-10.asc"],
137+
)
138+
139+
http_file(
140+
name = "buster_archive_security_key",
141+
sha256 = "4cf886d6df0fc1c185ce9fb085d1cd8d678bc460e6267d80a833d7ea507a0fbd",
142+
urls = ["https://ftp-master.debian.org/keys/archive-key-10-security.asc"],
143+
)
144+
145+
deb_packages(
146+
name = "debian_buster_armhf",
147+
arch = "armhf",
148+
distro = "buster",
149+
distro_type = "debian",
150+
mirrors = ["http://deb.debian.org/debian"],
151+
packages = {
152+
"dash": "pool/main/d/dash/dash_0.5.10.2-5_armhf.deb",
153+
},
154+
packages_sha256 = {
155+
"dash": "4287aa31a5c1d9e32f077e90194b37f5d9af326630248c4a3df83c5d3965f219",
156+
},
157+
pgp_key = "buster_archive_key",
158+
)
159+
160+
deb_packages(
161+
name = "debian_buster_arm64",
162+
arch = "arm64",
163+
distro = "buster",
164+
distro_type = "debian",
165+
mirrors = ["http://deb.debian.org/debian"],
166+
packages = {
167+
"dash": "pool/main/d/dash/dash_0.5.10.2-5_arm64.deb",
168+
},
169+
packages_sha256 = {
170+
"dash": "63d948ae0479c25652798cb072ecb4a24ab281cda477224773f033b570760058",
171+
},
172+
pgp_key = "buster_archive_key",
173+
)
174+
175+
deb_packages(
176+
name = "debian_buster_amd64",
177+
arch = "amd64",
178+
distro = "buster",
179+
distro_type = "debian",
180+
mirrors = ["http://deb.debian.org/debian"],
181+
packages = {
182+
"dash": "pool/main/d/dash/dash_0.5.10.2-5_amd64.deb",
183+
},
184+
packages_sha256 = {
185+
"dash": "e4872d9f258e76665317c94c637b4270dc1c15c9cf42da90dbfde0225c7f4564",
186+
},
187+
pgp_key = "buster_archive_key",
188+
)
189+
122190
# docker base images
123191

124192
load("@io_bazel_rules_docker//container:container.bzl", "container_pull")
@@ -127,15 +195,15 @@ load("@io_bazel_rules_docker//container:container.bzl", "container_pull")
127195

128196
container_pull(
129197
name = "discolix_cc_linux_amd64",
130-
digest = "sha256:658214f6df3179a5edb3351ca945b7dd5800a880d80d8d43d9ac0010582fc9a4",
198+
digest = "sha256:96a7d582cbc74f094346b51894d6b855d3a43323084f8805d3c188ef1f32586c",
131199
registry = "index.docker.io",
132200
repository = "discolix/cc",
133201
tag = "latest-linux_amd64",
134202
)
135203

136204
container_pull(
137205
name = "discolix_cc_debug_linux_amd64",
138-
digest = "sha256:0b7f5e0552da5fde6a8df15dd8539539f0768eae21741f59044e206d9e2ab880",
206+
digest = "sha256:cdf4fd88dcc9cae6508084b50b7aa1e7834a065426b99989cebc6982de67db77",
139207
registry = "index.docker.io",
140208
repository = "discolix/cc",
141209
tag = "debug-linux_amd64",
@@ -145,15 +213,15 @@ container_pull(
145213

146214
container_pull(
147215
name = "discolix_cc_linux_arm64",
148-
digest = "sha256:cc46ce931ed0134df0736ff740a8f6c6fe9a66a396ad2274932ae111d4703098",
216+
digest = "sha256:b9d8dd4a3aa547d12651a1085db2296381d8ee593087f68ed84e13e66ef3f5a7",
149217
registry = "index.docker.io",
150218
repository = "discolix/cc",
151219
tag = "latest-linux_arm64",
152220
)
153221

154222
container_pull(
155223
name = "discolix_cc_debug_linux_arm64",
156-
digest = "sha256:c9c33f36b8ebf0b315e67cdac0e268d901453cfa59a145a76898de2ce78c79cf",
224+
digest = "sha256:f6e3d0c9b57c3924cab2f891e8f077f4f1390388fb3ca08eec5c85c7681ffcc2",
157225
registry = "index.docker.io",
158226
repository = "discolix/cc",
159227
tag = "debug-linux_arm64",
@@ -163,15 +231,15 @@ container_pull(
163231

164232
container_pull(
165233
name = "discolix_cc_linux_arm",
166-
digest = "sha256:e6c7d87bef1a9f94cb243d403d768d142077f3a97345ad568d48635109ad3591",
234+
digest = "sha256:d3e387995f8f1f892b00dd7da58a8dc87fab9b9ca8ec70692df674b390c4bdd8",
167235
registry = "index.docker.io",
168236
repository = "discolix/cc",
169237
tag = "latest-linux_arm",
170238
)
171239

172240
container_pull(
173241
name = "discolix_cc_debug_linux_arm",
174-
digest = "sha256:16a0f214a1e535b81346f6e0f684db8be1c4641939974d6a1206f669c119788e",
242+
digest = "sha256:4fb7463db2391762742fcbf8acbf8a5e0c251b7aa2eb8f83cf4e626c907a0394",
175243
registry = "index.docker.io",
176244
repository = "discolix/cc",
177245
tag = "debug-linux_arm",

Diff for: platforms/BUILD

+1-17
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ platform(
2121
)
2222

2323
config_setting(
24-
name = "is_linux_amd64",
24+
name = "is_linux_arm",
2525
constraint_values = [
2626
"@platforms//os:linux",
2727
"@platforms//cpu:x86_64",
@@ -36,26 +36,10 @@ platform(
3636
],
3737
)
3838

39-
config_setting(
40-
name = "is_linux_arm64",
41-
constraint_values = [
42-
"@platforms//os:linux",
43-
"@platforms//cpu:aarch64",
44-
],
45-
)
46-
4739
platform(
4840
name = "linux_arm",
4941
constraint_values = [
5042
"@platforms//os:linux",
5143
"@platforms//cpu:arm",
5244
],
5345
)
54-
55-
config_setting(
56-
name = "is_linux_arm",
57-
constraint_values = [
58-
"@platforms//os:linux",
59-
"@platforms//cpu:arm",
60-
],
61-
)

Diff for: tensorflow_model_server/BUILD

+79-45
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,16 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
load("@bazel_skylib//lib:selects.bzl", "selects")
1516
load(
1617
"@io_bazel_rules_docker//container:container.bzl",
1718
"container_bundle",
1819
"container_image",
20+
"container_layer",
1921
)
22+
load("@debian_buster_armhf//debs:deb_packages.bzl", "debian_buster_armhf")
23+
load("@debian_buster_arm64//debs:deb_packages.bzl", "debian_buster_arm64")
24+
load("@debian_buster_amd64//debs:deb_packages.bzl", "debian_buster_amd64")
2025

2126
cc_library(
2227
name = "main_lib",
@@ -25,12 +30,12 @@ cc_library(
2530
],
2631
linkstamp = "stamp.cc",
2732
deps = [
33+
"@tf_serving//tensorflow_serving/model_servers:server_lib",
2834
"@org_tensorflow//tensorflow/c:c_api",
2935
"@org_tensorflow//tensorflow/core:lib",
3036
"@org_tensorflow//tensorflow/core/platform/cloud:gcs_file_system",
3137
"@org_tensorflow//tensorflow/core/platform/hadoop:hadoop_file_system",
3238
"@org_tensorflow//tensorflow/core/platform/s3:s3_file_system",
33-
"@tf_serving//tensorflow_serving/model_servers:server_lib",
3439
],
3540
)
3641

@@ -46,70 +51,99 @@ cc_binary(
4651
],
4752
)
4853

49-
container_image(
50-
name = "image",
51-
base = select({
52-
"//platforms:is_linux_amd64": "@discolix_cc_linux_amd64//image",
53-
"//platforms:is_linux_arm64": "@discolix_cc_linux_arm64//image",
54-
"//platforms:is_linux_arm": "@discolix_cc_linux_arm//image",
55-
}),
56-
cmd = [
57-
"--model_name=model",
58-
"--model_base_path=/models/model",
54+
# docker
55+
56+
config_setting(
57+
name = "linux_arm",
58+
constraint_values = [
59+
"@platforms//os:linux",
60+
"@platforms//cpu:arm",
5961
],
60-
directory = "/usr/bin/",
61-
entrypoint = [
62-
"tensorflow_model_server",
63-
"--port=8500",
64-
"--rest_api_port=8501",
62+
)
63+
64+
config_setting(
65+
name = "linux_arm64",
66+
constraint_values = [
67+
"@platforms//os:linux",
68+
"@platforms//cpu:aarch64",
6569
],
66-
files = [":tensorflow_model_server"],
67-
ports = [
68-
"8500",
69-
"8501",
70+
)
71+
72+
config_setting(
73+
name = "linux_amd64",
74+
constraint_values = [
75+
"@platforms//os:linux",
76+
"@platforms//cpu:x86_64",
7077
],
71-
stamp = True,
78+
)
79+
80+
config_setting(
81+
name = "debug",
82+
define_values = {"image": "debug"},
83+
)
84+
85+
selects.config_setting_group(
86+
name = "linux_arm_debug",
87+
match_all = [":linux_arm", ":debug"],
88+
)
89+
90+
selects.config_setting_group(
91+
name = "linux_arm64_debug",
92+
match_all = [":linux_arm64", ":debug"],
93+
)
94+
95+
selects.config_setting_group(
96+
name = "linux_amd64_debug",
97+
match_all = [":linux_amd64", ":debug"],
98+
)
99+
100+
container_layer(
101+
name = "dash",
102+
debs = select({
103+
":linux_arm": [debian_buster_armhf["dash"]],
104+
":linux_arm64": [debian_buster_arm64["dash"]],
105+
":linux_amd64": [debian_buster_amd64["dash"]],
106+
}),
72107
)
73108

74109
container_image(
75-
name = "image_debug",
110+
name = "image",
76111
base = select({
77-
"//platforms:is_linux_amd64": "@discolix_cc_debug_linux_amd64//image",
78-
"//platforms:is_linux_arm64": "@discolix_cc_debug_linux_arm64//image",
79-
"//platforms:is_linux_arm": "@discolix_cc_debug_linux_arm//image",
112+
":linux_arm": "@discolix_cc_linux_arm//image",
113+
":linux_arm64": "@discolix_cc_linux_arm64//image",
114+
":linux_amd64": "@discolix_cc_linux_amd64//image",
115+
":linux_arm_debug": "@discolix_cc_debug_linux_arm//image",
116+
":linux_arm64_debug": "@discolix_cc_debug_linux_arm64//image",
117+
":linux_amd64_debug": "@discolix_cc_debug_linux_amd64//image",
80118
}),
81-
cmd = [
82-
"--model_name=model",
83-
"--model_base_path=/models/model",
84-
],
85119
directory = "/usr/bin/",
86-
entrypoint = [
87-
"tensorflow_model_server",
88-
"--port=8500",
89-
"--rest_api_port=8501",
120+
entrypoint = ["tf_serving_entrypoint.sh"],
121+
env = {
122+
"MODEL_NAME": "model",
123+
"MODEL_BASE_PATH": "/models",
124+
},
125+
files = [
126+
":tf_serving_entrypoint.sh",
127+
":tensorflow_model_server",
90128
],
91-
files = [":tensorflow_model_server"],
129+
layers = ["dash"],
92130
ports = [
93131
"8500",
94132
"8501",
95133
],
96134
stamp = True,
97135
)
98136

99-
# prepare project images for publishing
100-
101-
project_image_tags = [
102-
"linux_amd64_avx_sse4.2",
103-
"linux_arm64_armv8-a",
104-
"linux_arm64_armv8.2-a",
105-
"linux_arm_armv7-a_neon_vfpv4",
106-
"linux_arm_armv7-a_neon_vfpv3",
107-
]
108-
109137
# these targets only serve to give a project ":image" a fully qualified docker
110138
# image name and should always be accompanied by their respective config group like:
111139
# bazel run //tensorflow_model_server:linux_arm64_armv8-a --config=linux_arm64_armv8-a
112140
[container_bundle(
113141
name = tag,
114142
images = {"{PROJECT_REGISTRY_PREFIX}:{UPSTREAM_TFS_VERSION}-" + tag: ":image"},
115-
) for tag in project_image_tags]
143+
) for tag in [
144+
"linux_arm_armv7-a_neon_vfpv4",
145+
"linux_arm_armv7-a_neon_vfpv3",
146+
"linux_arm64_armv8.2-a",
147+
"linux_arm64_armv8-a",
148+
"linux_amd64_avx_sse4.2",
149+
]]

Diff for: tensorflow_model_server/tf_serving_entrypoint.sh

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
tensorflow_model_server --port=8500 --rest_api_port=8501 \
3+
--model_name=${MODEL_NAME} --model_base_path=${MODEL_BASE_PATH}/${MODEL_NAME} \
4+
"$@"

0 commit comments

Comments
 (0)