Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions deployment/build/development-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ echo "--- 1. Ensuring frontend submodule is synchronized ---"
echo "--- 2. Injecting Environment Configurations ---"

echo "Copying inference-orchestrator .env..."
cp "$CONFIG_PATH/inference-orchestrator/.env" "python-ecosystem/inference-orchestrator/.env"
cp "$CONFIG_PATH/inference-orchestrator/.env" "python-ecosystem/inference-orchestrator/src/.env"

echo "Copying rag-pipeline .env..."
cp "$CONFIG_PATH/rag-pipeline/.env" "python-ecosystem/rag-pipeline/.env"
Expand All @@ -43,11 +43,11 @@ echo "--- 3. Building Java Artifacts (mvn clean package) ---"
(cd "$JAVA_DIR" && mvn clean package -DskipTests)

echo "--- 4. MCP Servers jar update ---"
cp "$MCP_SERVERS_JAR_PATH" python-ecosystem/inference-orchestrator/codecrow-vcs-mcp-1.0.jar
cp "$MCP_SERVERS_JAR_PATH" python-ecosystem/inference-orchestrator/src/codecrow-vcs-mcp-1.0.jar

echo "--- 4.1. Platform MCP jar update ---"
if [ -f "$PLATFORM_MCP_JAR_PATH" ]; then
cp "$PLATFORM_MCP_JAR_PATH" python-ecosystem/inference-orchestrator/codecrow-platform-mcp-1.0.jar
cp "$PLATFORM_MCP_JAR_PATH" python-ecosystem/inference-orchestrator/src/codecrow-platform-mcp-1.0.jar
echo "Platform MCP JAR copied successfully."
else
echo "Warning: Platform MCP JAR not found at $PLATFORM_MCP_JAR_PATH"
Expand Down
6 changes: 3 additions & 3 deletions deployment/build/production-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ echo "Frontend at: $(cd "$FRONTEND_DIR" && git log --oneline -1)"
echo "--- 2. Injecting Environment Configurations ---"

echo "Copying inference-orchestrator .env..."
cp "$CONFIG_PATH/inference-orchestrator/.env" "python-ecosystem/inference-orchestrator/.env"
cp "$CONFIG_PATH/inference-orchestrator/.env" "python-ecosystem/inference-orchestrator/src/.env"

echo "Copying rag-pipeline .env..."
cp "$CONFIG_PATH/rag-pipeline/.env" "python-ecosystem/rag-pipeline/.env"
Expand All @@ -43,11 +43,11 @@ echo "--- 3. Building Java Artifacts (mvn clean package) ---"
(cd "$JAVA_DIR" && mvn clean package)

echo "--- 4. MCP Servers jar update ---"
cp "$MCP_SERVERS_JAR_PATH" python-ecosystem/inference-orchestrator/codecrow-vcs-mcp-1.0.jar
cp "$MCP_SERVERS_JAR_PATH" python-ecosystem/inference-orchestrator/src/codecrow-vcs-mcp-1.0.jar

echo "--- 4.1. Platform MCP jar update ---"
if [ -f "$PLATFORM_MCP_JAR_PATH" ]; then
cp "$PLATFORM_MCP_JAR_PATH" python-ecosystem/inference-orchestrator/codecrow-platform-mcp-1.0.jar
cp "$PLATFORM_MCP_JAR_PATH" python-ecosystem/inference-orchestrator/src/codecrow-platform-mcp-1.0.jar
echo "Platform MCP JAR copied successfully."
else
echo "Warning: Platform MCP JAR not found at $PLATFORM_MCP_JAR_PATH"
Expand Down
10 changes: 5 additions & 5 deletions deployment/ci/ci-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ echo "=========================================="
echo "--- 1. Writing .env files from CI secrets ---"

if [ -n "${ENV_INFERENCE_ORCHESTRATOR:-}" ]; then
echo "$ENV_INFERENCE_ORCHESTRATOR" > python-ecosystem/inference-orchestrator/.env
echo " ✓ inference-orchestrator/.env written"
echo "$ENV_INFERENCE_ORCHESTRATOR" > python-ecosystem/inference-orchestrator/src/.env
echo " ✓ inference-orchestrator/src/.env written"
fi

if [ -n "${ENV_RAG_PIPELINE:-}" ]; then
Expand All @@ -55,11 +55,11 @@ echo " ✓ Java build & tests complete"

# ── 3. Copy MCP JARs ──────────────────────────────────────────────────────
echo "--- 3. Copying MCP server JARs ---"
cp "$MCP_JAR" python-ecosystem/inference-orchestrator/codecrow-vcs-mcp-1.0.jar
cp "$MCP_JAR" python-ecosystem/inference-orchestrator/src/codecrow-vcs-mcp-1.0.jar
echo " ✓ VCS MCP JAR copied"

if [ -f "$PLATFORM_MCP_JAR" ]; then
cp "$PLATFORM_MCP_JAR" python-ecosystem/inference-orchestrator/codecrow-platform-mcp-1.0.jar
cp "$PLATFORM_MCP_JAR" python-ecosystem/inference-orchestrator/src/codecrow-platform-mcp-1.0.jar
echo " ✓ Platform MCP JAR copied"
else
echo " ⚠ Platform MCP JAR not found (optional)"
Expand All @@ -71,7 +71,7 @@ echo "--- 4. Building Docker images ---"
IMAGES=(
"codecrow/web-server|java-ecosystem/services/web-server|Dockerfile.observable"
"codecrow/pipeline-agent|java-ecosystem/services/pipeline-agent|Dockerfile.observable"
"codecrow/inference-orchestrator|python-ecosystem/inference-orchestrator"
"codecrow/inference-orchestrator|python-ecosystem/inference-orchestrator/src|Dockerfile.observable"
"codecrow/rag-pipeline|python-ecosystem/rag-pipeline"
"codecrow/web-frontend|frontend"
)
Expand Down
1 change: 1 addition & 0 deletions deployment/ci/server-deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ for cfg in \
"$CONFIG_DIR/java-shared/newrelic-web-server.yml" \
"$CONFIG_DIR/java-shared/newrelic-pipeline-agent.yml" \
"$CONFIG_DIR/inference-orchestrator/.env" \
"$CONFIG_DIR/inference-orchestrator/newrelic.ini" \
"$CONFIG_DIR/rag-pipeline/.env"; do
if [ ! -f "$cfg" ]; then
echo "ERROR: Missing config file: $cfg"
Expand Down
24 changes: 23 additions & 1 deletion deployment/ci/server-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,27 @@ SAMPLE
fi
done

# New Relic config for inference-orchestrator (Python agent)
NR_INI="$DEPLOY_DIR/config/inference-orchestrator/newrelic.ini"
if [ ! -f "$NR_INI" ]; then
cat > "$NR_INI" <<'SAMPLE'
# ============================================================================
# New Relic Python agent config for inference-orchestrator
# See https://docs.newrelic.com/docs/apm/agents/python-agent/configuration/python-agent-configuration/
# Copy your newrelic.ini here with your license_key and app_name
# ============================================================================
[newrelic]
license_key = REPLACE_WITH_YOUR_LICENSE_KEY
app_name = CodeCrow Inference Orchestrator
monitor_mode = true
log_level = info
SAMPLE
echo " ✓ Created placeholder: inference-orchestrator/newrelic.ini"
echo " → EDIT THIS FILE with your New Relic license key!"
else
echo " ○ inference-orchestrator/newrelic.ini already exists (skipped)"
fi

# Docker Compose .env (DB creds, internal secrets — never committed to git)
ENV_FILE="$DEPLOY_DIR/.env"
if [ ! -f "$ENV_FILE" ]; then
Expand Down Expand Up @@ -126,7 +147,8 @@ echo " │ ├── newrelic-pipeline-agent.yml ← YOUR New Relic con
echo " │ └── github-private-key/"
echo " │ └── *.pem ← YOUR GitHub App key"
echo " ├── inference-orchestrator/"
echo " │ └── .env ← YOUR secrets"
echo " │ ├── .env ← YOUR secrets"
echo " │ └── newrelic.ini ← YOUR New Relic Python agent config"
echo " └── rag-pipeline/"
echo " └── .env ← YOUR secrets"
echo ""
Expand Down
1 change: 1 addition & 0 deletions deployment/docker-compose.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ services:
- codecrow-network
volumes:
- ./config/inference-orchestrator/.env:/app/.env
- ./config/inference-orchestrator/newrelic.ini:/app/newrelic.ini:ro
restart: unless-stopped
extra_hosts:
- "host.docker.internal:host-gateway"
Expand Down
2 changes: 1 addition & 1 deletion deployment/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ services:

inference-orchestrator:
build:
context: ../python-ecosystem/inference-orchestrator
context: ../python-ecosystem/inference-orchestrator/src
container_name: codecrow-inference-orchestrator
ports:
- "127.0.0.1:8000:8000"
Expand Down
18 changes: 18 additions & 0 deletions python-ecosystem/inference-orchestrator/src/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr

target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/

.env
server.log
*.jar

logs/**
**/__pycache__/
newrelic.ini
90 changes: 90 additions & 0 deletions python-ecosystem/inference-orchestrator/src/Dockerfile.observable
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
FROM python:3.11-slim-bullseye AS builder

# Set work directory
WORKDIR /app

# --- Builder Stage 1: Install Dependencies ---
COPY requirements.txt .

# Install build dependencies required by some Python packages
RUN apt-get update && \
apt-get install -y --no-install-recommends \
gcc \
libc-dev \
&& apt-get clean && \
rm -rf /var/lib/apt/lists/*

# Install Python dependencies
RUN pip install --no-cache-dir -r requirements.txt


# --- Builder Stage 2: Copy and Install Application Modules ---
# Copy application source code and the JAR
COPY main.py .
COPY api ./api/
COPY server ./server/
COPY model ./model/
COPY service ./service/
COPY utils ./utils/
COPY llm ./llm/
# Copy the JAR files (required by the Python service)
COPY codecrow-vcs-mcp-1.0.jar ./codecrow-vcs-mcp-1.0.jar
# Platform MCP JAR - if it exists (optional)
COPY codecrow-platform-mcp-1.0.jar* ./

# --- Production Stage ---
FROM python:3.11-slim-bullseye

# CRITICAL FIX: Pull a slim JRE from eclipse-temurin instead of using apt-get
# This saves ~150-200MB compared to installing openjdk-17-jre-headless via apt
COPY --from=eclipse-temurin:17-jre /opt/java/openjdk /opt/java/openjdk
ENV JAVA_HOME=/opt/java/openjdk
ENV PATH="${JAVA_HOME}/bin:${PATH}"

RUN apt-get update && \
apt-get install -y --no-install-recommends \
curl && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

# Create non-root user and set permissions
RUN groupadd -r appuser && useradd -r -g appuser appuser
RUN mkdir -p /app && chown -R appuser:appuser /app

WORKDIR /app

# Copy installed dependencies directly from the builder stage
COPY --from=builder /usr/local/lib/python3.11/site-packages /usr/local/lib/python3.11/site-packages
# Copy pip-installed executables (newrelic-admin, uvicorn, etc.)
COPY --from=builder /usr/local/bin/ /usr/local/bin/

# Copy application code from the builder stage
COPY --chown=appuser:appuser --from=builder /app/main.py ./
COPY --chown=appuser:appuser --from=builder /app/api ./api/
COPY --chown=appuser:appuser --from=builder /app/server ./server/
COPY --chown=appuser:appuser --from=builder /app/model ./model/
COPY --chown=appuser:appuser --from=builder /app/service ./service/
COPY --chown=appuser:appuser --from=builder /app/utils ./utils/
COPY --chown=appuser:appuser --from=builder /app/llm ./llm/
# Copy the JAR files
COPY --chown=appuser:appuser --from=builder /app/codecrow-vcs-mcp-1.0.jar ./codecrow-vcs-mcp-1.0.jar
# Copy Platform MCP JAR if present
COPY --chown=appuser:appuser --from=builder /app/codecrow-platform-mcp-1.0.jar* ./

# Set PYTHONPATH environment variable to include the current working directory.
ENV PYTHONPATH=/app

# ── New Relic observability ──────────────────────────────────────────────────
# The newrelic package is already installed via requirements.txt.
# Config file (newrelic.ini) is mounted at runtime via docker-compose volume.
ENV NEW_RELIC_CONFIG_FILE=/app/newrelic.ini
ENV NEW_RELIC_LOG_FILE_NAME=STDOUT

# Switch to non-root user
USER appuser

# Expose port (default for FastAPI/Uvicorn)
EXPOSE 8000

# Run via newrelic-admin for APM instrumentation
CMD ["newrelic-admin", "run-program", "python", "main.py"]
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ langchain-anthropic>=1.0.0,<2.0.0
langchain-google-genai>=4.0.0
mcp-use
redis>=5.0.0
newrelic==11.5.0