my-homepage/BUILD

75 lines
1.8 KiB
Python

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",
)
load("@rules_python//python:defs.bzl", "py_library", "py_test")
load("@my_deps//:requirements.bzl", "requirement")
# python library with my website code
py_library(
name = "shillerben-homepage-lib",
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"),
]
)
# test my website with pytest
py_test(
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",
],
deps = [
":shillerben-homepage-lib",
requirement("pytest"),
],
)
# 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
container_push(
name = "push-image",
image = ":shillerben-homepage-img",
format = "Docker",
registry = "docker.shillerben.com",
repository = "shillerben-homepage",
tag = "latest",
#extract_config = ":.docker-config.json",
)