This PR enhances the Docker build and deployment process for the Arcade Worker by: - **Modularizing Docker Builds:** - Introduces a new `INSTALL_TOOLKITS` build argument in the `Dockerfile` to conditionally include toolkits. this enables the creation of a `arcadeai/worker-base` which can be used to build custom containers in a multi-stage build. an example of this is included in the example dir. - Adds `docker-base` Makefile target to build a lightweight base image without toolkits. - **Publishing to GitHub Container Registry (GHCR):** - Adds Makefile targets `publish-ghcr` and `gh-login` for pushing images to GHCR. - Supports publishing both base and full images with toolkits to GHCR. - **Docker Compose:** - Add Docker compose file and setup - Renames the `actor` service to `worker` - Adds an `nginx` service in `docker-compose.yml` to proxy requests to the Arcade Engine. - Introduces an `nginx.conf` file for the Nginx service. - **Streamlining Toolkit Installation:** - Moves toolkit installation from the `start.sh` script to the Docker build process. - Creates a `toolkits.txt` file to manage toolkit dependencies which can be edited easily when we want to add a new toolkit. Developers can also use this approach as shown in the example. - **Improving Configuration Files:** - Updates `docker.engine.yaml` and `env.example` to align with the new setup. TODO: - CI/CD needs to be adjusted so that images are pushed to ghcr on release. - AWS resources need to be renamed actor -> worker @EricGustin This can go in after the above two items are resolved. --------- Co-authored-by: Wils Dawson <wils@arcade-ai.com> Co-authored-by: Eric Gustin <34000337+EricGustin@users.noreply.github.com> Co-authored-by: sdreyer <sterling@arcade-ai.com> Co-authored-by: Sterling Dreyer <sdreyer21@gmail.com> Co-authored-by: Nate Barbettini <nathanaelb@gmail.com>
39 lines
945 B
Python
39 lines
945 B
Python
import os
|
|
|
|
from modal import App, Image, asgi_app
|
|
|
|
# Define the FastAPI app
|
|
app = App("arcade-worker")
|
|
|
|
toolkits = ["arcade-google", "arcade-slack"]
|
|
|
|
image = (
|
|
Image.debian_slim()
|
|
.pip_install("arcade-ai[fastapi]")
|
|
.pip_install(toolkits)
|
|
.pip_install("fastapi>=0.115.3")
|
|
.pip_install("uvicorn>=0.24.0")
|
|
)
|
|
|
|
|
|
@app.function(image=image)
|
|
@asgi_app()
|
|
def fastapi_app():
|
|
from fastapi import FastAPI
|
|
|
|
from arcade.sdk import Toolkit
|
|
from arcade.worker.fastapi.worker import FastAPIWorker
|
|
|
|
web_app = FastAPI()
|
|
|
|
# Initialize app and Arcade FastAPIWorker
|
|
worker_secret = os.environ.get("ARCADE_WORKER_SECRET", "dev")
|
|
worker = FastAPIWorker(web_app, secret=worker_secret)
|
|
|
|
# Register toolkits we've installed
|
|
installed_toolkits = Toolkit.find_all_arcade_toolkits()
|
|
for toolkit in toolkits:
|
|
if toolkit in installed_toolkits:
|
|
worker.register_toolkit(toolkit)
|
|
|
|
return web_app
|