Skip to content

Commit

Permalink
feat(backend): Docker for deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
RezaRahemtola committed Nov 12, 2024
1 parent a745426 commit 57fa208
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
13 changes: 13 additions & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM python:3.12

WORKDIR /app

RUN pip install poetry

COPY ./pyproject.toml ./poetry.lock ./

RUN poetry install

COPY . .

CMD ["poetry", "run", "fastapi", "run", "src/main.py", "--host", "0.0.0.0"]
10 changes: 10 additions & 0 deletions backend/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
services:
agents-api:
build:
dockerfile: ./Dockerfile
container_name: libertai-agents
restart: unless-stopped
ports:
- "8082:8000"
env_file:
- .env
20 changes: 18 additions & 2 deletions backend/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,5 +222,21 @@ async def update(

@app.delete("/agent", description="Remove an agent on subscription end")
async def delete(body: DeleteAgentBody):
# TODO
pass
agents = await fetch_agents([body.subscription_id])

if len(agents) != 1:
raise HTTPException(
status_code=HTTPStatus.NOT_FOUND,
detail=f"Agent for subscription ID {body.subscription_id} not found.",
)
agent = agents[0]

aleph_account = ETHAccount(config.ALEPH_SENDER_SK)
async with AuthenticatedAlephHttpClient(
account=aleph_account, api_server=config.ALEPH_API_URL
) as client:
await client.forget(
address=config.ALEPH_OWNER,
hashes=[agent.vm_hash],
reason="LibertAI Agent subscription ended",
)

0 comments on commit 57fa208

Please sign in to comment.