diff --git a/Dockerfile b/Dockerfile index 079792af..f15af803 100644 --- a/Dockerfile +++ b/Dockerfile @@ -57,7 +57,7 @@ RUN set -eux; \ esac; \ apt-get update && \ # Install curl, Python, and PostgreSQL client libraries - apt-get install -y curl python3 python3-venv libpq-dev && \ + apt-get install -y curl python3 python3-venv libpq-dev redis-server && \ # Install Node.js curl -fsSL https://deb.nodesource.com/setup_${NODE_VERSION}.x | bash - && \ apt-get install -y nodejs && \ @@ -95,7 +95,7 @@ COPY --from=builder /app . # Copy initialization SQL if it exists COPY init.sql /docker-entrypoint-initdb.d/ -EXPOSE 8283 5432 4317 4318 +EXPOSE 8283 5432 6379 4317 4318 ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"] CMD ["./letta/server/startup.sh"] diff --git a/letta/server/startup.sh b/letta/server/startup.sh index 5d8d736a..94a8fd58 100755 --- a/letta/server/startup.sh +++ b/letta/server/startup.sh @@ -12,6 +12,29 @@ wait_for_postgres() { done } +# Function to wait for Redis to be ready +wait_for_redis() { + until redis-cli ping 2>/dev/null | grep -q PONG; do + echo "Waiting for Redis to be ready..." + sleep 1 + done +} + +# Check if we're configured for external Redis +if [ -n "$LETTA_REDIS_HOST" ]; then + echo "External Redis configuration detected, using env var LETTA_REDIS_HOST=$LETTA_REDIS_HOST" +else + echo "No external Redis configuration detected, starting internal Redis..." + redis-server --daemonize yes --bind 0.0.0.0 + + # Wait for Redis to be ready + wait_for_redis + + # Set default Redis host for internal redis + export LETTA_REDIS_HOST="localhost" + echo "Using internal Redis at: $LETTA_REDIS_HOST" +fi + # Check if we're configured for external Postgres if [ -n "$LETTA_PG_URI" ]; then echo "External Postgres configuration detected, using env var LETTA_PG_URI"