Skip to content

Commit 08660ec

Browse files
committed
chore: add postgres service
1 parent 912706b commit 08660ec

File tree

3 files changed

+51
-0
lines changed

3 files changed

+51
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
-- Initialize databases
2+
-- This script runs first to ensure both databases exist
3+
4+
-- Create the coagent database (this might already exist from POSTGRES_DB env var)
5+
SELECT 'CREATE DATABASE coagent'
6+
WHERE NOT EXISTS (SELECT FROM pg_database WHERE datname = 'coagent')\gexec
7+
8+
-- Create the coagent-cloud database
9+
SELECT 'CREATE DATABASE "coagent-cloud"'
10+
WHERE NOT EXISTS (SELECT FROM pg_database WHERE datname = 'coagent-cloud')\gexec
11+
12+
-- Grant permissions to coagent user on both databases
13+
GRANT ALL PRIVILEGES ON DATABASE coagent TO coagent;
14+
GRANT ALL PRIVILEGES ON DATABASE "coagent-cloud" TO coagent;
15+
16+
\echo 'Successfully ensured both coagent and coagent-cloud databases exist'
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
-- Initialize coagent-cloud database with organizations, users, and subscriptions tables
2+
-- This script runs automatically when PostgreSQL container starts
3+
-- Database creation is handled in 00-init-databases.sql
4+
5+
-- Connect to the coagent-cloud database
6+
\c "coagent-cloud";
7+
8+
-- Enable UUID extension
9+
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
10+
11+
-- Grant permissions (assuming coagent user exists)
12+
GRANT ALL PRIVILEGES ON DATABASE "coagent-cloud" TO coagent;
13+
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO coagent;
14+
GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public TO coagent;
15+
GRANT USAGE ON SCHEMA public TO coagent;

docker-compose.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ services:
2727
depends_on:
2828
clickhouse:
2929
condition: service_healthy
30+
postgres:
31+
condition: service_healthy
3032
pull_policy: if_not_present
3133

3234
clickhouse:
@@ -81,5 +83,23 @@ services:
8183
- local-llm
8284
entrypoint: [ "/bin/bash", "-c", "ollama serve & sleep 5 && ollama pull all-minilm && ollama pull qwen3:4b && wait" ]
8385

86+
postgres:
87+
image: postgres:16-alpine
88+
ports:
89+
- "5432:5432"
90+
environment:
91+
POSTGRES_USER: "coagent"
92+
POSTGRES_PASSWORD: "coagent"
93+
POSTGRES_DB: "coagent"
94+
volumes:
95+
- .volumes/postgres/data:/var/lib/postgresql/data:z
96+
- ./config/postgres/initdb.d:/docker-entrypoint-initdb.d:ro
97+
healthcheck:
98+
test: [ "CMD-SHELL", "pg_isready -U coagent -d coagent" ]
99+
interval: 30s
100+
timeout: 10s
101+
retries: 5
102+
start_period: 30s
103+
84104
volumes:
85105
ollama_storage:

0 commit comments

Comments
 (0)