- Problem Statement [Click Here]
Note: Make sure to have a .env in ./agent_code folder which container the db url
DATABASE_URL=postgresql://admin:root@postgres_db:5432/test_dbDOCKER COMPOSE ENDPOINTS
-
postgres
- POSTGRES USER:
admin - POSTGRES PASSWORD:
root - POSTGRES DEFAULT DB:
test_db - POSTGRES PORT:
5432
- POSTGRES USER:
-
pg-admin(for db-UI)
- PGADMIN DEFAULT EMAIL:
mohitmolela@gmail.com - PGADMIN DEFAULT PASSWORD:
root - PORTS:
5050
- PGADMIN DEFAULT EMAIL:
-
landing-page(frontend)
- PORT:
5173 - VITE_API_URL=
http://localhost:8000 - DATABASE_URL=
postgresql://admin:root@db:5432/test_db - ENCRYPTION_SECRET=
12345678901234567890123456789012 - NEXTAUTH_URL=
http://localhost:5173 - NEXT_PUBLIC_VIEWER_URL=
http://localhost:5173
- PORT:
-
Flask Agent
- PORT:
8000
- PORT:
-
loki
- PORT:
3100
- PORT:
-
grafana
- PORT:
3000
- PORT:
Run the following command to start your Docker services:
docker compose up -dThis starts the PostgreSQL container in detached mode.
verify that it is running:
docker psEnsure PostgreSQL is running and mapped to port 5432.
(Optional but recommended)
Check container logs:
docker logs <postgres-container-name>You should see a message like:
database system is ready to accept connections
First, list all containers:
docker ps -aThen access the PostgreSQL container:
docker exec -it <container-name-or-id> /bin/bashBefore applying the schema, ensure the database exists.
Inside the container:
psql -U <user>Create the database:
CREATE DATABASE <database-name>;Exit:
\qFrom your host machine:
docker cp path/to/host/machine/company_db_schema.sql <container-name>:/company_db_schema.sqldocker cp path/to/host/machine/inserts.sql <container-name>:/inserts.sqlInside the container:
psql -U <user> -d <database-name> -f ./company_db_schema.sqlThis creates all tables and database structures.
psql -U <user> -d <database-name> -f ./inserts.sqlThis populates the tables with initial records.
To manually access the database:
psql -U <user> -d <database-name>Inside PostgreSQL CLI:
List tables:
\dtList databases:
\lDescribe a table:
\d <table-name>- Start Docker container
- Verify PostgreSQL is running
- Create database
- Copy schema and data files
- Execute schema
- Insert data
- Verify tables
Your PostgreSQL database should now be fully set up and ready for use.