42 lines
1.3 KiB
Python
42 lines
1.3 KiB
Python
import modal
|
|
from dotenv import dotenv_values
|
|
|
|
from BowongModalFunctions.config import WorkerConfig
|
|
|
|
config = WorkerConfig()
|
|
|
|
fastapi_image = (
|
|
modal.Image
|
|
.debian_slim(python_version="3.11")
|
|
.pip_install_from_pyproject("../pyproject.toml")
|
|
.env(dotenv_values("../.runtime.env"))
|
|
.add_local_python_source('cluster')
|
|
.add_local_python_source('BowongModalFunctions')
|
|
)
|
|
|
|
app = modal.App(
|
|
name="web_app",
|
|
image=fastapi_image,
|
|
secrets=[modal.Secret.from_name("aws-s3-secret", environment_name=config.modal_environment)],
|
|
include_source=False)
|
|
|
|
with fastapi_image.imports():
|
|
from BowongModalFunctions.api import web_app
|
|
|
|
|
|
@app.function(scaledown_window=60,
|
|
secrets=[
|
|
modal.Secret.from_name("cf-kv-secret", environment_name='dev'),
|
|
],
|
|
volumes={
|
|
config.S3_mount_dir: modal.CloudBucketMount(
|
|
bucket_name=config.S3_bucket_name,
|
|
secret=modal.Secret.from_name("aws-s3-secret",
|
|
environment_name=config.modal_environment),
|
|
),
|
|
}, )
|
|
@modal.concurrent(max_inputs=100)
|
|
@modal.asgi_app()
|
|
def fastapi_webapp():
|
|
return web_app
|