2023-02-01 21:37:16 +00:00
|
|
|
load("@aspect_rules_py//py:defs.bzl", "py_binary")
|
2023-02-01 22:36:56 +00:00
|
|
|
load("@io_bazel_rules_docker//python3:image.bzl", "py3_image")
|
|
|
|
load("@io_bazel_rules_docker//container:container.bzl", "container_push")
|
2023-02-01 21:37:16 +00:00
|
|
|
|
2023-02-01 22:36:56 +00:00
|
|
|
def fastapi_binary(name, image_name, path, port, deps = [], tags = [], **kwargs):
|
2023-02-01 21:37:16 +00:00
|
|
|
py_binary(
|
|
|
|
name = name,
|
|
|
|
srcs = ["@pypi_hypercorn//:rules_python_wheel_entry_point_hypercorn.py"],
|
|
|
|
args = ["{}:app".format(path), "--reload", "--bind 127.0.0.1:{}".format(port)],
|
|
|
|
visibility = ["//:__subpackages__"],
|
|
|
|
deps = deps + [
|
|
|
|
":{}_lib".format(name),
|
|
|
|
"@pypi_hypercorn//:pkg",
|
|
|
|
],
|
|
|
|
tags = tags + [
|
|
|
|
"ibazel_notify_changes",
|
|
|
|
],
|
|
|
|
**kwargs
|
|
|
|
)
|
|
|
|
|
2023-02-01 22:36:56 +00:00
|
|
|
py3_image(
|
|
|
|
name = "{}.image".format(name),
|
2023-02-01 21:37:16 +00:00
|
|
|
srcs = ["@pypi_hypercorn//:rules_python_wheel_entry_point_hypercorn.py"],
|
2023-02-01 22:36:56 +00:00
|
|
|
main = "@pypi_hypercorn//:rules_python_wheel_entry_point_hypercorn.py",
|
2023-02-01 22:50:15 +00:00
|
|
|
args = ["{}:app".format(path)],
|
2023-02-01 21:37:16 +00:00
|
|
|
visibility = ["//:__subpackages__"],
|
|
|
|
deps = deps + [
|
|
|
|
":{}_lib".format(name),
|
|
|
|
"@pypi_hypercorn//:pkg",
|
|
|
|
],
|
|
|
|
tags = tags + [
|
|
|
|
"ibazel_notify_changes",
|
|
|
|
],
|
|
|
|
**kwargs
|
|
|
|
)
|
2023-02-01 22:36:56 +00:00
|
|
|
|
|
|
|
container_push(
|
|
|
|
name = "{}.push".format(name),
|
|
|
|
format = "Docker",
|
|
|
|
image = ":{}.image".format(name),
|
|
|
|
registry = "ghcr.io",
|
|
|
|
repository = "resf/{}".format(image_name),
|
|
|
|
tag = "{BUILD_TAG}",
|
|
|
|
visibility = ["//visibility:public"],
|
|
|
|
)
|