Hi Agno Community/Developers,
We’re encountering an issue setting up our local development database using Agno (ag ws up
) where the specified custom user is not being created during the initial database setup on a fresh Docker volume.
Our Setup:
- Agno project with standard
workspace/dev_resources.py
. - Using
PgVectorDb
resource to define the local database container. - Target configuration: User
jpsn
, Databaseai
, Password specified. .env
file correctly configured for local connections (DB_USER=jpsn
,DB_DATABASE=ai
,DB_HOST=localhost
, etc.).- Initially used the default
PgVectorDb
image (agnohq/pgvector:16
), also tested withpgvector/pgvector:pg16
.
Configuration in dev_resources.py
:
# In jpsn-app/workspace/dev_resources.py
from agno.docker.app.postgres import PgVectorDb
# (or from agno.docker.app.postgres import PostgresDb if testing that)
# ... other imports ...
dev_db = PgVectorDb( # Or PostgresDb(...) if testing base class
name="jpsn-app-db",
# image_name="...", # Tried agnohq/pgvector:16 and pgvector/pgvector:pg16
# image_tag="...",
pg_user="jpsn", # Target user
pg_password="<our_password>", # Target password
pg_database="ai", # Target database
host_port=5432,
)
# ... rest of dev_resources.py defining container_env using dev_db.get_db_* methods ...
Problem Description:
When we attempt to start the local development environment from a completely clean state (ensuring the database Docker volume is removed), the database container fails to initialize correctly with the specified jpsn
user.
Steps Taken (Repeatedly):
- Run
ag ws down
. - Identify the correct database Docker volume (e.g.,
jpsn-app-db-volume
) usingdocker volume ls
. - Successfully remove the volume using
docker volume rm <volume_name>
(confirmed removal withdocker volume ls
). - Run
ag ws up
.
Observed Behavior:
- DB Container Logs: Show signs of fresh initialization (e.g.,
CREATE DATABASE
,CREATE EXTENSION
, crucially no “Skipping initialization” message). However, there’s no explicit log confirming userjpsn
creation. - API/App Container Logs: Often show successful connection (
Connected to tcp://jpsn-app-db:5432
) and sometimes successful internal Alembic migration checks (likely due to trust authentication within the Docker network). - Host Connection Attempts (
psql
/PGAdmin/Local Alembic): When trying to connect from the host machine tolocalhost:5432
as userjpsn
to databaseai
, we consistently get:
FATAL: role "jpsn" does not exist
- Default User Failure: Attempts to connect as the default
postgres
user (e.g.,psql -U postgres -d postgres
) also fail withFATAL: role "postgres" does not exist
, even after configuringdev_resources.py
to usepg_user="postgres"
andpg_database="postgres"
during initialization. - Container Env Variables Confirmed: Running
docker exec <db_container_id> printenv | grep POSTGRES
confirms that the database container is being launched with the correct environment variables (POSTGRES_USER=jpsn
,POSTGRES_PASSWORD=<our_password>
,POSTGRES_DB=ai
) based on thedev_resources.py
configuration.
Conclusion:
Despite the Agno framework correctly setting the standard POSTGRES_
environment variables for the database container, the initialization scripts within the tested images (agnohq/pgvector:16
, pgvector/pgvector:pg16
) are failing to create the specified user (jpsn
) or even the default postgres
user reliably when starting with an empty volume in our Agno setup.
Questions:
- Is this a known issue with
PgVectorDb
/PostgresDb
or these specific images within the Agno environment? - Is there a different or additional configuration required in
dev_resources.py
(e.g., specificenv_vars
, different parameters) to ensure user creation works correctly during initialization with these images? - What is the recommended approach within Agno to reliably initialize a local PostgreSQL/PgVector database with a custom user and password when starting from a clean volume?
Any insights or suggestions would be greatly appreciated!