From 06bb60e89c83a8d1162334061b2ea5ed60709868 Mon Sep 17 00:00:00 2001 From: Clay McCullough Date: Thu, 11 Jul 2024 06:23:47 -0500 Subject: [PATCH] stack is working (#161) * stack is working * working dockerfile cleaned up --- docker-compose.dev.yaml | 120 ++++++++++++++++++++++++++++++++++++++++ docker-compose.yaml | 22 ++++---- pants.toml | 3 + stack/BUILD | 2 + stack/Dockerfile | 24 +------- 5 files changed, 138 insertions(+), 33 deletions(-) create mode 100644 docker-compose.dev.yaml diff --git a/docker-compose.dev.yaml b/docker-compose.dev.yaml new file mode 100644 index 00000000..fca54290 --- /dev/null +++ b/docker-compose.dev.yaml @@ -0,0 +1,120 @@ +services: + # stack: + # build: + # context: ./stack + # dockerfile: Dockerfile + # container_name: PersonaStack + # # restart: on-failure + # ports: + # - "9000:9000" + # networks: + # - net + # env_file: + # - .env.production + postgres-db: + # Use a custom Docker build context for PostgreSQL. + build: ./contrib/postgresql + container_name: postgres-db + restart: on-failure + environment: + - POSTGRES_USER=postgres + - POSTGRES_PASSWORD=postgres + ports: + - "5432:5432" + volumes: + - postgresql_data:/var/lib/postgresql/data + networks: + - net + healthcheck: + test: ["CMD", "pg_isready", "-q", "-d", "postgres", "-U", "postgres"] + interval: 5s + timeout: 5s + retries: 5 + qdrant: + image: qdrant/qdrant:latest + restart: always + container_name: qdrant + ports: + - 6333:6333 + - 6334:6334 + expose: + - 6333 + - 6334 + - 6335 + configs: + - source: qdrant_config + target: ./contrib/qdrant/config/config.yaml + volumes: + - ./qdrant_data:/qdrant_data + networks: + - net + unstructured-api: + env_file: + - .env + image: quay.io/unstructured-io/unstructured-api:latest + container_name: unstructured-api + environment: + - UNSTRUCTURED_API_KEY=${UNSTRUCTURED_API_KEY} + ports: + - 8000:8000 + networks: + - net + # langfuse-server: + # image: langfuse/langfuse:latest + # container_name: langfuse + # platform: linux/amd64 + # depends_on: + # postgres-db: + # condition: service_healthy + # ports: + # - "3000:3000" + # networks: + # - net + # environment: + # - DATABASE_URL=postgresql://postgres:postgres@postgres-db:5432/langfuse + # - NEXTAUTH_SECRET=mysecret + # - SALT=mysalt + # - NEXTAUTH_URL=http://localhost:3000 + # - TELEMETRY_ENABLED=${TELEMETRY_ENABLED:-true} + # - LANGFUSE_ENABLE_EXPERIMENTAL_FEATURES=${LANGFUSE_ENABLE_EXPERIMENTAL_FEATURES:-false} + # phoenix: + # image: arizephoenix/phoenix:latest + # container_name: phoenix + # platform: linux/amd64 + # depends_on: + # postgres-db: + # condition: service_healthy + # networks: + # - net + # ports: + # - 6006:6006 # PHOENIX_PORT + # - 4317:4317 # PHOENIX_GRPC_PORT + # - 9090:9090 # [Optional] PROMETHEUS PORT IF ENABLED + # environment: + # - PHOENIX_SQL_DATABASE_URL=postgresql://postgres:postgres@postgres-db:5432/phoenix + # - PHOENIX_WORKING_DIR=/phoenix + # Uncomment if you want to run local models using ollama docker image + # ollama: + # image: ollama/ollama + # container_name: embed-ollama + # ports: + # - 11435:11434 + # volumes: + # - ./models:/root/.ollama/models + +configs: + qdrant_config: + content: | + log_level: INFO + +networks: + net: +volumes: + qdrant_data: + driver: local + postgresql_data: + driver: local + langfuse_data: + driver: local + # models: + # driver: local diff --git a/docker-compose.yaml b/docker-compose.yaml index fca54290..3673859a 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,16 +1,14 @@ services: - # stack: - # build: - # context: ./stack - # dockerfile: Dockerfile - # container_name: PersonaStack - # # restart: on-failure - # ports: - # - "9000:9000" - # networks: - # - net - # env_file: - # - .env.production + stack: + image: personaflow/stack:latest + container_name: stack + # restart: on-failure + ports: + - "9000:9000" + networks: + - net + env_file: + - .env.production postgres-db: # Use a custom Docker build context for PostgreSQL. build: ./contrib/postgresql diff --git a/pants.toml b/pants.toml index 0ff66f46..ab0749fe 100644 --- a/pants.toml +++ b/pants.toml @@ -50,3 +50,6 @@ resolves = { python-default = "constraints.txt"} # problematic system Pythons. See # https://www.pantsbuild.org/docs/python-interpreter-compatibility#changing-the-interpreter-search-path. search_path = ["", ""] + +[docker] +build_verbose = true diff --git a/stack/BUILD b/stack/BUILD index 28cab72a..a38313f2 100644 --- a/stack/BUILD +++ b/stack/BUILD @@ -9,6 +9,8 @@ pex_binary( docker_image( name="docker", + dependencies=[":local"], + repository="personaflow/stack" ) shell_sources() diff --git a/stack/Dockerfile b/stack/Dockerfile index d2745a86..fc299c2b 100644 --- a/stack/Dockerfile +++ b/stack/Dockerfile @@ -43,26 +43,8 @@ ENV ENVIRONMENT='' \ AZURE_OPENAI_DEPLOYMENT_NAME='' \ AZURE_OPENAI_API_BASE='' \ AZURE_OPENAI_API_KEY='' \ - AZURE_OPENAI_API_VERSION='' \ - POETRY_NO_INTERACTION=1 \ - POETRY_VIRTUALENVS_IN_PROJECT=1 \ - POETRY_VIRTUALENVS_CREATE=1 \ - POETRY_CACHE_DIR=/tmp/poetry_cache -RUN apt-get update && apt-get upgrade && apt-get clean && apt-get install -y libmagic1 + AZURE_OPENAI_API_VERSION='' -FROM base as builder -WORKDIR /app +COPY stack/local.pex /bin/app - -COPY pyproject.toml poetry.lock /app/ -RUN pip install --upgrade pip \ - && pip install poetry \ - && poetry config virtualenvs.in-project true \ - && poetry install --without dev --no-root - -FROM base as runner -WORKDIR /app -COPY --from=builder /app /app -COPY . /app -EXPOSE 9000 -CMD ["/app/.venv/bin/uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "9000"] +ENTRYPOINT ["/usr/local/bin/python3.11", "/bin/app"]