To add your own resources, just create a python file, define resources and add them to a DockerResources
, AwsResources
or K8sResources
object.
workspace/dev_resources.py
from phi.docker.app.fastapi import FastApi
from phi.docker.app.postgres import PgVectorDb
from phi.docker.app.streamlit import Streamlit
from phi.docker.resources import DockerResources
dev_image = DockerImage(
...
)
dev_db = PgVectorDb(
...
)
dev_streamlit = Streamlit(
...
)
dev_fastapi = FastApi(
...
)
dev_docker_resources = DockerResources(
env=ws_settings.dev_env,
network=ws_settings.ws_name,
apps=[dev_db, dev_streamlit, dev_fastapi, dev_jupyter_app],
)
workspace/prd_resources.py
from phi.aws.app.fastapi import FastApi
from phi.aws.app.streamlit import Streamlit
from phi.aws.resources import AwsResources
from phi.aws.resource.ecs import EcsCluster
from phi.aws.resource.ec2 import SecurityGroup, InboundRule
from phi.aws.resource.rds import DbInstance, DbSubnetGroup
from phi.aws.resource.reference import AwsReference
from phi.aws.resource.s3 import S3Bucket
from phi.aws.resource.secret import SecretsManager
from phi.docker.resources import DockerResources
from phi.docker.resource.image import DockerImage
prd_image = DockerImage(
...
)
prd_bucket = S3Bucket(
...
)
prd_secret = SecretsManager(
...
)
prd_db_secret = SecretsManager(
...
)
prd_lb_sg = SecurityGroup(
...
)
prd_sg = SecurityGroup(
...
)
prd_db_port = 5432
prd_db_sg = SecurityGroup(
...
)
prd_db_subnet_group = DbSubnetGroup(
...
)
prd_db = DbInstance(
...
)
prd_streamlit = Streamlit(
...
)
prd_fastapi = FastApi(
...
)
prd_docker_resources = DockerResources(
env=ws_settings.prd_env,
network=ws_settings.ws_name,
resources=[prd_image],
)
prd_aws_resources = AwsResources(
env=ws_settings.prd_env,
apps=[prd_streamlit, prd_fastapi],
resources=[prd_lb_sg, prd_sg, prd_db_sg, prd_secret, prd_db_secret, prd_db_subnet_group, prd_db, prd_bucket],
)