Skip to content

Commit

Permalink
Clean up Docker Compose (#1368)
Browse files Browse the repository at this point in the history
* Fix hatchet, dockerfile

* Update compose

* point to correct docker image
  • Loading branch information
NolanTrem authored Oct 10, 2024
1 parent ca9acdf commit 87c1e9e
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 129 deletions.
8 changes: 4 additions & 4 deletions py/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ COPY --from=builder /usr/local/lib/python3.10/site-packages /usr/local/lib/pytho
COPY --from=builder /usr/local/bin /usr/local/bin

# Expose the port and set environment variables
ARG PORT=8000 HOST=0.0.0.0
ENV PORT=$PORT HOST=$HOST
EXPOSE $PORT
ARG R2R_PORT=8000 HOST=0.0.0.0
ENV R2R_PORT=$R2R_PORT HOST=$HOST
EXPOSE $R2R_PORT

COPY . /app
# Copy the application and config
Expand All @@ -47,4 +47,4 @@ COPY r2r.toml /app/r2r.toml
COPY pyproject.toml /app/pyproject.toml

# Run the application
CMD ["sh", "-c", "uvicorn core.main.app_entry:app --host $HOST --port $PORT"]
CMD ["sh", "-c", "uvicorn core.main.app_entry:app --host $HOST --port $R2R_PORT"]
139 changes: 64 additions & 75 deletions py/compose.full.yaml
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
networks:
r2r-network:
name: r2r-network
driver: bridge
attachable: true
ipam:
driver: default
config:
- subnet: 172.28.0.0/16
labels:
- "com.docker.compose.recreate=always"

volumes:
hatchet_certs:
name: ${VOLUME_HATCHET_CERTS:-hatchet_certs}
hatchet_config:
name: ${VOLUME_HATCHET_CONFIG:-hatchet_config}
hatchet_api_key:
name: ${VOLUME_HATCHET_API_KEY:-hatchet_api_key}
postgres_data:
name: ${VOLUME_POSTGRES_DATA:-postgres_data}
hatchet_rabbitmq_data:
hatchet_rabbitmq.conf:
name: ${VOLUME_HATCHET_RABBITMQ_DATA:-hatchet_rabbitmq_data}
hatchet_rabbitmq_conf:
name: ${VOLUME_HATCHET_RABBITMQ_CONF:-hatchet_rabbitmq_conf}

services:
postgres:
Expand All @@ -33,7 +34,7 @@ services:
networks:
- r2r-network
ports:
- "5432:5432"
- "${R2R_POSTGRES_PORT:-5432}:5432"
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-postgres}"]
interval: 10s
Expand All @@ -48,14 +49,14 @@ services:
image: "rabbitmq:3-management"
hostname: "hatchet-rabbitmq"
ports:
- "5673:5672"
- "15673:15672"
- "${R2R_RABBITMQ_PORT:-5673}:5672"
- "${R2R_RABBITMQ_MGMT_PORT:-15673}:15672"
environment:
RABBITMQ_DEFAULT_USER: "user"
RABBITMQ_DEFAULT_PASS: "password"
volumes:
- "hatchet_rabbitmq_data:/var/lib/rabbitmq"
- "hatchet_rabbitmq.conf:/etc/rabbitmq/rabbitmq.conf"
- hatchet_rabbitmq_data:/var/lib/rabbitmq
- hatchet_rabbitmq_conf:/etc/rabbitmq/rabbitmq.conf
healthcheck:
test: ["CMD", "rabbitmqctl", "status"]
interval: 10s
Expand Down Expand Up @@ -85,7 +86,7 @@ services:
POSTGRES_USER: "${POSTGRES_USER:-postgres}"
POSTGRES_PASSWORD: "${POSTGRES_PASSWORD:-postgres}"
POSTGRES_HOST: "${POSTGRES_HOST:-postgres}"
POSTGRES_PORT: "${POSTGRES_PORT:-5432}"
POSTGRES_PORT: "${R2R_POSTGRES_PORT:-5432}"
HATCHET_POSTGRES_DBNAME: "${HATCHET_POSTGRES_DBNAME:-hatchet}"
networks:
- r2r-network
Expand All @@ -96,10 +97,10 @@ services:
POSTGRES_USER: "${POSTGRES_USER:-postgres}"
POSTGRES_PASSWORD: "${POSTGRES_PASSWORD:-postgres}"
POSTGRES_HOST: "${POSTGRES_HOST:-postgres}"
POSTGRES_PORT: "${POSTGRES_PORT:-5432}"
POSTGRES_PORT: "${R2R_POSTGRES_PORT:-5432}"
HATCHET_POSTGRES_DBNAME: "${HATCHET_POSTGRES_DBNAME:-hatchet}"
DATABASE_URL: "postgres://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD:-postgres}@${POSTGRES_HOST:-postgres}:${POSTGRES_PORT:-5432}/${HATCHET_POSTGRES_DBNAME:-hatchet}?sslmode=disable"
DATABASE_POSTGRES_PORT: "${POSTGRES_PORT:-5432}"
DATABASE_POSTGRES_PORT: "${R2R_POSTGRES_PORT:-5432}"
DATABASE_POSTGRES_HOST: "${POSTGRES_HOST:-postgres}"
DATABASE_POSTGRES_USERNAME: "${POSTGRES_USER:-postgres}"
DATABASE_POSTGRES_PASSWORD: "${POSTGRES_PASSWORD:-postgres}"
Expand Down Expand Up @@ -128,12 +129,12 @@ services:
DATABASE_POSTGRES_PASSWORD: "${POSTGRES_PASSWORD:-postgres}"
HATCHET_DATABASE_POSTGRES_DB_NAME: "${HATCHET_POSTGRES_DBNAME:-hatchet}"
SERVER_TASKQUEUE_RABBITMQ_URL: amqp://user:password@hatchet-rabbitmq:5672/
SERVER_AUTH_COOKIE_DOMAIN: "http://host.docker.internal:7274"
SERVER_URL: "http://host.docker.internal:7274"
SERVER_AUTH_COOKIE_DOMAIN: "http://host.docker.internal:${R2R_HATCHET_DASHBOARD_PORT:-7274}"
SERVER_URL: "http://host.docker.internal:${R2R_HATCHET_DASHBOARD_PORT:-7274}"
SERVER_AUTH_COOKIE_INSECURE: "t"
SERVER_GRPC_BIND_ADDRESS: "0.0.0.0"
SERVER_GRPC_INSECURE: "t"
SERVER_GRPC_BROADCAST_ADDRESS: "host.docker.internal:7077"
SERVER_GRPC_BROADCAST_ADDRESS: "hatchet-engine:7077"
SERVER_GRPC_MAX_MSG_SIZE: 13421772800
volumes:
- hatchet_certs:/hatchet/certs
Expand All @@ -154,17 +155,17 @@ services:
hatchet-setup-config:
condition: service_completed_successfully
ports:
- "7077:7077"
- "${R2R_HATCHET_ENGINE_PORT:-7077}:7077"
environment:
POSTGRES_USER: "${POSTGRES_USER:-postgres}"
POSTGRES_PASSWORD: "${POSTGRES_PASSWORD:-postgres}"
POSTGRES_HOST: "${POSTGRES_HOST:-postgres}"
POSTGRES_PORT: "${POSTGRES_PORT:-5432}"
HATCHET_POSTGRES_DBNAME: "${HATCHET_POSTGRES_DBNAME:-hatchet}"
DATABASE_URL: "postgres://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD:-postgres}@${POSTGRES_HOST:-postgres}:${POSTGRES_PORT:-5432}/${HATCHET_POSTGRES_DBNAME:-hatchet}?sslmode=disable"
SERVER_GRPC_BROADCAST_ADDRESS: "host.docker.internal:7077"
SERVER_GRPC_BROADCAST_ADDRESS: "hatchet-engine:7077"
SERVER_GRPC_BIND_ADDRESS: "0.0.0.0"
SERVER_GRPC_PORT: 7077
SERVER_GRPC_PORT: "7077"
SERVER_GRPC_INSECURE: "t"
SERVER_GRPC_MAX_MSG_SIZE: 13421772800
SERVER_LOGGER_LEVEL: warn
Expand All @@ -175,9 +176,7 @@ services:
- hatchet_certs:/hatchet/certs
- hatchet_config:/hatchet/config
networks:
r2r-network:
aliases:
- host.docker.internal
- r2r-network
healthcheck:
test: ["CMD", "wget", "-q", "-O", "-", "http://localhost:8733/live"]
interval: 10s
Expand All @@ -197,17 +196,14 @@ services:
POSTGRES_HOST: host.docker.internal
POSTGRES_PORT: "${POSTGRES_PORT:-5432}"
HATCHET_POSTGRES_DBNAME: "${HATCHET_POSTGRES_DBNAME:-hatchet}"
DATABASE_URL: "postgres://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD:-postgres}@${POSTGRES_HOST:-host.docker.internal}:${POSTGRES_PORT:-5432}/${HATCHET_POSTGRES_DBNAME:-hatchet}?sslmode=disable"
DATABASE_URL: "postgres://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD:-postgres}@${POSTGRES_HOST:-host.docker.internal}:${R2R_POSTGRES_PORT:-5432}/${HATCHET_POSTGRES_DBNAME:-hatchet}?sslmode=disable"
volumes:
- hatchet_certs:/hatchet/certs
- hatchet_config:/hatchet/config
networks:
- r2r-network
labels:
- "traefik.enable=true"
- "traefik.http.routers.hatchet-dashboard.rule=PathPrefix(`/`)"
- "traefik.http.services.hatchet-frontend.loadbalancer.server.port=80"
- "traefik.http.routers.hatchet-dashboard.entrypoints=hatchet"
ports:
- "${R2R_HATCHET_DASHBOARD_PORT:-7274}:80"

setup-token:
image: ghcr.io/hatchet-dev/hatchet/hatchet-admin:v0.49.0-alpha.4
Expand Down Expand Up @@ -287,55 +283,84 @@ services:
unstructured:
image: ${UNSTRUCTURED_IMAGE:-ragtoriches/unst-prod}
ports:
- "7275:7275"
- "${R2R_UNSTRUCTURED_PORT:-7275}:7275"
networks:
- r2r-network
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:7275/health"]
interval: 10s
timeout: 5s
retries: 5

r2r:
image: ${R2R_IMAGE:-ragtoriches/prod:latest-unstructured}
image: ${R2R_IMAGE:-ragtoriches/prod:latest}
build:
context: .
args:
PORT: ${PORT:-7272}
PORT: ${R2R_PORT:-${PORT:-7272}} # Eventually get rid of PORT, but for now keep it for backwards compatibility
R2R_PORT: ${R2R_PORT:-${PORT:-7272}}
ports:
- "${PORT:-7272}:${PORT:-7272}"
- "${R2R_PORT:-${PORT:-7272}}:${R2R_PORT:-${PORT:-7272}}"
environment:
- PYTHONUNBUFFERED=1
- PORT=${PORT:-7272}
- R2R_PORT=${R2R_PORT:-${PORT:-7272}} # Eventually get rid of PORT, but for now keep it for backwards compatibility
- HOST=${HOST:-0.0.0.0}

# R2R
- CONFIG_NAME=${CONFIG_NAME:-}
- CONFIG_PATH=${CONFIG_PATH:-}

# Postgres
- POSTGRES_USER=${POSTGRES_USER:-postgres}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-postgres}
- POSTGRES_HOST=${POSTGRES_HOST:-postgres}
- POSTGRES_PORT=${POSTGRES_PORT:-5432}
- POSTGRES_DBNAME=${POSTGRES_DBNAME:-postgres}
- POSTGRES_MAX_CONNECTIONS=${POSTGRES_MAX_CONNECTIONS:-}
- POSTGRES_PROJECT_NAME=${POSTGRES_PROJECT_NAME:-r2r_default}
- R2R_PROJECT_NAME=${R2R_PROJECT_NAME:-r2r_default}
- POSTGRES_MAX_CONNECTIONS=${POSTGRES_MAX_CONNECTIONS:-1024}

# OpenAI
- OPENAI_API_KEY=${OPENAI_API_KEY:-}
- OPENAI_API_BASE=${OPENAI_API_BASE:-}

# Anthropic
- ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY:-}

# Azure
- AZURE_API_KEY=${AZURE_API_KEY:-}
- AZURE_API_BASE=${AZURE_API_BASE:-}
- AZURE_API_VERSION=${AZURE_API_VERSION:-}

# Google Vertex AI
- GOOGLE_APPLICATION_CREDENTIALS=${GOOGLE_APPLICATION_CREDENTIALS:-}
- VERTEX_PROJECT=${VERTEX_PROJECT:-}
- VERTEX_LOCATION=${VERTEX_LOCATION:-}

# AWS Bedrock
- AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID:-}
- AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY:-}
- AWS_REGION_NAME=${AWS_REGION_NAME:-}

# Groq
- GROQ_API_KEY=${GROQ_API_KEY:-}

# Cohere
- COHERE_API_KEY=${COHERE_API_KEY:-}

# Anyscale
- ANYSCALE_API_KEY=${ANYSCALE_API_KEY:-}

# Ollama
- OLLAMA_API_BASE=${OLLAMA_API_BASE:-http://host.docker.internal:11434}

# Unstructured
- UNSTRUCTURED_API_KEY=${UNSTRUCTURED_API_KEY:-}
- UNSTRUCTURED_API_URL=${UNSTRUCTURED_API_URL:-https://api.unstructured.io/general/v0/general}
- UNSTRUCTURED_LOCAL_URL=${UNSTRUCTURED_LOCAL_URL:-http://unstructured:7275}
- UNSTRUCTURED_NUM_WORKERS=${UNSTRUCTURED_NUM_WORKERS:-10}

# Hatchet
- HATCHET_CLIENT_TLS_STRATEGY=none
- HATCHET_CLIENT_GRPC_MAX_RECV_MESSAGE_LENGTH=${HATCHET_CLIENT_GRPC_MAX_RECV_MESSAGE_LENGTH:-13421772800}
- HATCHET_CLIENT_GRPC_MAX_SEND_MESSAGE_LENGTH=${HATCHET_CLIENT_GRPC_MAX_SEND_MESSAGE_LENGTH:-13421772800}
Expand All @@ -344,31 +369,19 @@ services:
if [ -z "$${HATCHET_CLIENT_TOKEN}" ]; then
export HATCHET_CLIENT_TOKEN=$$(cat /hatchet_api_key/api_key.txt)
fi
exec uvicorn core.main.app_entry:app --host $${HOST} --port $${PORT}
exec uvicorn core.main.app_entry:app --host $${HOST} --port $${R2R_PORT}
'
networks:
- r2r-network
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:${PORT:-7272}/v2/health"]
test: ["CMD", "curl", "-f", "http://localhost:${R2R_PORT:-7272}/v2/health"]
interval: 6s
timeout: 5s
retries: 5
restart: on-failure
volumes:
- ${CONFIG_PATH:-/}:${CONFIG_PATH:-/app/config}
- hatchet_api_key:/hatchet_api_key:ro
labels:
- "traefik.enable=true"
- "traefik.http.routers.r2r.rule=PathPrefix(`/r2r-api`)"
- "traefik.http.services.r2r.loadbalancer.server.port=${PORT:-7272}"
- "traefik.http.middlewares.r2r-strip-prefix.stripprefix.prefixes=/api"
- "traefik.http.middlewares.r2r-strip-prefix.stripprefix.prefixes=/r2r-api"
- "traefik.http.middlewares.r2r-add-v2.addprefix.prefix=/v2"
- "traefik.http.routers.r2r.middlewares=r2r-strip-prefix,r2r-add-v2,r2r-headers"
- "traefik.http.middlewares.r2r-headers.headers.customrequestheaders.Access-Control-Allow-Origin=*"
- "traefik.http.middlewares.r2r-headers.headers.customrequestheaders.Access-Control-Allow-Methods=GET,POST,OPTIONS"
- "traefik.http.middlewares.r2r-headers.headers.customrequestheaders.Access-Control-Allow-Headers=DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization"
- "traefik.http.middlewares.r2r-headers.headers.customresponseheaders.Access-Control-Expose-Headers=Content-Length,Content-Range"
extra_hosts:
- host.docker.internal:host-gateway
depends_on:
Expand All @@ -380,32 +393,8 @@ services:
r2r-dashboard:
image: emrgntcmplxty/r2r-dashboard:latest
environment:
- NEXT_PUBLIC_API_URL=http://localhost:${R2R_DASHBOARD_PORT:-8001}/r2r-api
- NEXT_PUBLIC_API_URL=http://localhost:${R2R_PORT:-7272}/r2r-api
networks:
- r2r-network
labels:
- "traefik.enable=true"
- "traefik.http.routers.r2r-dashboard.rule=PathPrefix(`/`)"
- "traefik.http.services.r2r-dashboard.loadbalancer.server.port=3000"
- "traefik.http.routers.r2r-dashboard.entrypoints=r2r"

traefik:
image: traefik:v2.9
command:
- "--api.insecure=true"
- "--providers.docker=true"
- "--providers.docker.exposedbydefault=false"
- "--entrypoints.r2r.address=:${R2R_DASHBOARD_PORT:-8001}"
- "--entrypoints.hatchet.address=:${HATCHET_DASHBOARD_PORT:-8002}"
- "--accesslog=true"
- "--accesslog.filepath=/var/log/traefik/access.log"
ports:
- "${R2R_DASHBOARD_PORT:-8001}:${R2R_DASHBOARD_PORT:-8001}"
- "${HATCHET_DASHBOARD_PORT:-8002}:${HATCHET_DASHBOARD_PORT:-8002}"
- "${TRAEFIK_DASHBOARD_PORT:-8081}:${TRAEFIK_DASHBOARD_PORT:-8081}"
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
networks:
- r2r-network
labels:
- "traefik.http.middlewares.no-cache-headers.headers.customResponseHeaders.Cache-Control=no-cache, no-store, must-revalidate"
- "${R2R_DASHBOARD_PORT:-7273}:3000"
Loading

0 comments on commit 87c1e9e

Please sign in to comment.