diff options
author | Ben Sima <ben@bsima.me> | 2024-12-20 13:21:43 -0500 |
---|---|---|
committer | Ben Sima <ben@bsima.me> | 2024-12-21 10:08:11 -0500 |
commit | 32d31ae8d1ef5d5aeb03a7fe7e6a294e14905505 (patch) | |
tree | 4a248394a7c49682f9ef7538e3033fbea5117690 /Biz/Storybook.py | |
parent | 87ead51331bc57326882055e1635a84c2d409af7 (diff) |
Build and deploy storybook
I put the storybook into a new Biz.nix deploy target. The idea here is that any
Biz/* targets should be hosted by this one VM for simplicity. Over time I can
grow this as need be, but this should work to host a few services.
Diffstat (limited to 'Biz/Storybook.py')
-rw-r--r-- | Biz/Storybook.py | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/Biz/Storybook.py b/Biz/Storybook.py index 80f746a..c29d9f5 100644 --- a/Biz/Storybook.py +++ b/Biz/Storybook.py @@ -45,9 +45,11 @@ import unittest import uuid import uvicorn -VPN = True CODEROOT = pathlib.Path(os.getenv("CODEROOT", ".")) -DATA_DIR = pathlib.Path(CODEROOT / "_/var/storybook/") +DATA_DIR = pathlib.Path( + os.environ.get("DATA_DIR", CODEROOT / "_/var/storybook/"), +) +PORT = int(os.environ.get("PORT", "3000")) class Area(enum.Enum): @@ -89,15 +91,16 @@ def main() -> None: def move(area: Area) -> None: """Run the application.""" - Log.setup(logging.DEBUG if area.Test else logging.ERROR) + Log.setup(logging.DEBUG if area == Area.Test else logging.ERROR) logging.info("area: %s", area) - host = "100.127.197.132" if VPN else "127.0.0.1" - uvicorn.run(app, host=host) + # during test, bind to beryllium's VPN address, else localhost + host = "100.127.197.132" if area == Area.Test else "127.0.0.1" + uvicorn.run(app, host=host, port=PORT) def test(area: Area = Area.Test) -> None: """Run the unittest suite manually.""" - Log.setup(logging.DEBUG if area.Test else logging.ERROR) + Log.setup(logging.DEBUG if area == Area.Test else logging.ERROR) suite = unittest.TestSuite() tests = [IndexTest, StoryTest] suite.addTests([ |