my-homepage/BUILD

75 lines
1.8 KiB
Python
Raw Normal View History

2022-09-15 01:07:51 +00:00
load(
"@io_bazel_rules_docker//container:container.bzl",
"container_image",
"container_push",
)
#load("@docker_config//:push.bzl", my_container_push = "container_push")
load(
"@io_bazel_rules_docker//python3:image.bzl",
"py3_image",
)
2022-09-14 02:24:34 +00:00
load("@rules_python//python:defs.bzl", "py_library", "py_test")
load("@my_deps//:requirements.bzl", "requirement")
2022-09-15 01:07:51 +00:00
# python library with my website code
2022-09-14 02:24:34 +00:00
py_library(
2022-09-15 01:07:51 +00:00
name = "shillerben-homepage-lib",
2022-09-14 02:24:34 +00:00
srcs = ["my_homepage/__init__.py"],
data = glob(["my_homepage/templates/*"]),
deps = [
requirement("click"),
requirement("Flask"),
requirement("gunicorn"),
requirement("itsdangerous"),
requirement("Jinja2"),
requirement("MarkupSafe"),
requirement("Werkzeug"),
]
)
2022-09-15 01:07:51 +00:00
# test my website with pytest
2022-09-14 02:24:34 +00:00
py_test(
2022-09-15 01:07:51 +00:00
name = "website-test",
main = "my_homepage/test/run_pytest.py",
args = ["-s", "-v", "my_homepage"],
srcs = [
"my_homepage/test/run_pytest.py",
"my_homepage/test/test_website.py",
],
2022-09-14 02:24:34 +00:00
deps = [
2022-09-15 01:07:51 +00:00
":shillerben-homepage-lib",
2022-09-14 02:24:34 +00:00
requirement("pytest"),
],
)
2022-09-15 01:07:51 +00:00
# custom base image layer to set envs and cmd
container_image(
name = "website-base-py3",
base = "@py3_image_base//image",
ports = ["4040"],
)
py3_image(
name = "shillerben-homepage-img",
base = ":website-base-py3",
main = "main/__main__.py",
args = ["-b", "0.0.0.0:4040", "my_homepage:create_app()"],
srcs = [
"main/__main__.py",
],
deps = [
":shillerben-homepage-lib",
],
)
# push new website image
2022-09-14 02:24:34 +00:00
container_push(
name = "push-image",
2022-09-15 01:07:51 +00:00
image = ":shillerben-homepage-img",
2022-09-14 02:24:34 +00:00
format = "Docker",
registry = "docker.shillerben.com",
repository = "shillerben-homepage",
tag = "latest",
2022-09-15 01:07:51 +00:00
#extract_config = ":.docker-config.json",
2022-09-14 02:24:34 +00:00
)