From b5ea01b7de7f84b0f2d6ca8184ad8e2d8e0adbb4 Mon Sep 17 00:00:00 2001 From: Abram Date: Tue, 9 Jul 2024 09:54:12 +0100 Subject: [PATCH] refactor (tools): added postgres-related image to gh compose and added db src for migration --- docker-compose.gh.yml | 51 ++++++++++++++++++++++++++++++++++++++++++- docker-compose.yml | 1 + 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/docker-compose.gh.yml b/docker-compose.gh.yml index 42cfa7433a..513143698b 100644 --- a/docker-compose.gh.yml +++ b/docker-compose.gh.yml @@ -16,9 +16,11 @@ services: image: ghcr.io/agenta-ai/agenta-backend environment: - MONGODB_URI=mongodb://username:password@mongo:27017 + - POSTGRES_URI=postgresql+asyncpg://username:password@postgres:5432/agenta_oss - REDIS_URL=redis://redis:6379/0 - ENVIRONMENT=production - DATABASE_MODE=v2 + - MIGRATION_SRC_MONGO_DB_NAME=v2 - FEATURE_FLAG=oss - AGENTA_TEMPLATE_REPO=agentaai/templates_v2 - POSTHOG_API_KEY=phc_hmVSxIjTW1REBHXgj2aw4HW9X6CXb6FzerBgP9XenC7 @@ -60,6 +62,8 @@ services: depends_on: mongo: condition: service_healthy + postgres: + condition: service_healthy restart: always agenta-web: @@ -140,16 +144,17 @@ services: command: > celery -A agenta_backend.main.celery_app worker --concurrency=1 --loglevel=INFO environment: + - POSTGRES_URI=postgresql+asyncpg://username:password@postgres:5432/agenta_oss - MONGODB_URI=mongodb://username:password@mongo:27017 - REDIS_URL=redis://redis:6379/0 - CELERY_BROKER_URL=amqp://guest@rabbitmq// - CELERY_RESULT_BACKEND=redis://redis:6379/0 - FEATURE_FLAG=oss volumes: - - ./agenta-backend/agenta_backend:/app/agenta_backend - /var/run/docker.sock:/var/run/docker.sock depends_on: - mongo + - postgres - rabbitmq - redis extra_hosts: @@ -157,6 +162,48 @@ services: networks: - agenta-network + postgres: + image: postgres:16.2 + container_name: postgres + restart: always + environment: + POSTGRES_USER: username + POSTGRES_PASSWORD: password + POSTGRES_DB: agenta_oss + ports: + - "5432:5432" + networks: + - agenta-network + volumes: + - postgresdb-data:/var/lib/postgresql/data/ + - ./docker-assets/postgres/init-db.sql:/docker-entrypoint-initdb.d/init-db.sql + healthcheck: + test: ["CMD-SHELL", "pg_isready -U postgres"] + interval: 10s + timeout: 5s + retries: 5 + + pgadmin: + image: dpage/pgadmin4 + restart: always + environment: + PGADMIN_DEFAULT_EMAIL: "admin@example.com" + PGADMIN_DEFAULT_PASSWORD: "password" + PGADMIN_SERVER_HOST: "postgres" + PGADMIN_SERVER_PORT: 5432 + PGADMIN_SERVER_USER: "username" + PGADMIN_SERVER_PASSWORD: "password" + PGADMIN_SERVER_DB: agenta_oss + ports: + - "5050:80" + networks: + - agenta-network + volumes: + - pgadmin-data:/var/lib/pgadmin + depends_on: + postgres: + condition: service_healthy + networks: agenta-network: name: agenta-network @@ -164,3 +211,5 @@ networks: volumes: mongodb_data: redis_data: + postgresdb-data: + pgadmin-data: diff --git a/docker-compose.yml b/docker-compose.yml index c65c102680..ee40ca9aaa 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -19,6 +19,7 @@ services: - REDIS_URL=redis://redis:6379/0 - ENVIRONMENT=development - DATABASE_MODE=v2 + - MIGRATION_SRC_MONGO_DB_NAME=v2 - BARE_DOMAIN_NAME=localhost - DOMAIN_NAME=http://localhost - FEATURE_FLAG=oss