diff --git a/.gitignore b/.gitignore index 433d25c..336dbfb 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,10 @@ instance/ .coverage htmlcov/ +.docker-config.json + dist/ build/ *.egg-info/ + +bazel-* diff --git a/BUILD b/BUILD new file mode 100644 index 0000000..10d3efe --- /dev/null +++ b/BUILD @@ -0,0 +1,37 @@ +load("@io_bazel_rules_docker//container:container.bzl", "container_push") +load("@rules_python//python:defs.bzl", "py_library", "py_test") +load("@my_deps//:requirements.bzl", "requirement") + +py_library( + name = "shillerben-homepage", + 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"), + ] +) + +py_test( + name = "website_test", + main = "test_website.py", + srcs = ["tests/test_website.py"], + deps = [ + ":shillerben-homepage", + requirement("pytest"), + ], +) + +container_push( + name = "push-image", + image = ":shillerben-homepage", + format = "Docker", + registry = "docker.shillerben.com", + repository = "shillerben-homepage", + tag = "latest", +) diff --git a/Dockerfile b/Dockerfile index 0035220..040d932 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.8 +FROM python:3.10 WORKDIR /app diff --git a/WORKSPACE b/WORKSPACE new file mode 100644 index 0000000..f394fdf --- /dev/null +++ b/WORKSPACE @@ -0,0 +1,48 @@ +#workspace("my-homepage") + +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +load("@rules_python//python:repositories.bzl", "python_register_toolchains") +load("@python310//:defs.bzl", "interpreter") +load("@rules_python//python:pip.bzl", "pip_install") +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +load("@io_bazel_rules_docker//toolchains/docker:toolchain.bzl", + docker_toolchain_configure="toolchain_configure" +) +load( + "@io_bazel_rules_docker//repositories:repositories.bzl", + container_repositories = "repositories", +) +load("@io_bazel_rules_docker//repositories:deps.bzl", container_deps = "deps") + +http_archive( + name = "rules_python", + sha256 = "b593d13bb43c94ce94b483c2858e53a9b811f6f10e1e0eedc61073bd90e58d9c", + strip_prefix = "rules_python-0.12.0", + url = "https://github.com/bazelbuild/rules_python/archive/refs/tags/0.12.0.tar.gz", +) + +python_register_toolchains( + name = "python310", + python_version = "3.10.6", +) + +pip_install( + name = "my_deps", + python_interpreter_target = interpreter, + requirements = "//:requirements.txt" +) + +http_archive( + name = "io_bazel_rules_docker", + sha256 = "b1e80761a8a8243d03ebca8845e9cc1ba6c82ce7c5179ce2b295cd36f7e394bf", + urls = ["https://github.com/bazelbuild/rules_docker/releases/download/v0.25.0/rules_docker-v0.25.0.tar.gz"], +) + +docker_toolchain_configure( + name = "docker_config", + client_config = ":.docker-config.json", +) + +container_repositories() + +container_deps() diff --git a/requirements.txt b/requirements.txt index 41959c7..730358d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,3 +5,4 @@ itsdangerous==1.1.0 Jinja2==2.11.2 MarkupSafe==1.1.1 Werkzeug==1.0.1 +pytest