File tree Expand file tree Collapse file tree 4 files changed +71
-2
lines changed Expand file tree Collapse file tree 4 files changed +71
-2
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ firebase.json
19
19
build
20
20
dist
21
21
# Ignoring this for now
22
- /scripts
22
+ # /scripts
23
23
# Ignoring log files generated by tests
24
24
* .log
25
25
# Ignore some of the files that should be downloaded/generated for evaluation
Original file line number Diff line number Diff line change @@ -58,7 +58,7 @@ docs/user_guides/llm/vertexai/config
58
58
docs /** /config
59
59
60
60
# Ignoring this for now
61
- /scripts
61
+ # /scripts
62
62
63
63
# Ignoring log files generated by tests
64
64
firebase.json
Original file line number Diff line number Diff line change
1
+ FROM python:3.11-slim
2
+
3
+ # System dependencies
4
+ RUN apt-get update && apt-get install -y gcc g++ git curl \
5
+ && rm -rf /var/lib/apt/lists/*
6
+
7
+ WORKDIR /app
8
+
9
+ # Install Poetry
10
+ RUN pip install --no-cache-dir poetry
11
+
12
+ # Copy project files
13
+ COPY pyproject.toml poetry.lock* README.md ./
14
+ COPY examples/ ./examples/
15
+ COPY chat-ui/ ./chat-ui/
16
+ COPY nemoguardrails/ ./nemoguardrails/
17
+ COPY scripts/ ./scripts/
18
+ RUN chmod +x ./scripts/entrypoint.sh
19
+
20
+ # Create non-root user and set permissions
21
+ RUN useradd --create-home guardrails && \
22
+ mkdir -p /app/config && \
23
+ mkdir -p /app/.cache/pypoetry && \
24
+ chown -R guardrails:guardrails /app
25
+
26
+ USER guardrails
27
+
28
+ # Set Poetry cache and virtualenvs path
29
+ ENV POETRY_CACHE_DIR=/app/.cache/pypoetry
30
+ ENV POETRY_VIRTUALENVS_PATH=/app/.cache/pypoetry/virtualenvs
31
+
32
+ # Install all dependencies (main + extras) as non-root user
33
+ RUN poetry install --no-interaction --no-ansi --all-extras
34
+ RUN poetry run python -m spacy download en_core_web_lg
35
+
36
+ EXPOSE 8000
37
+
38
+ ENTRYPOINT ["./scripts/entrypoint.sh"]
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+
3
+ # Allow runtime overrides via env vars or args
4
+ CONFIG_ID=" ${CONFIG_ID:- $1 } "
5
+ PORT=" ${PORT:- $2 } "
6
+
7
+ # Set defaults if not provided
8
+ CONFIG_ID=" ${CONFIG_ID:- nemo} "
9
+ PORT=" ${PORT:- 8000} "
10
+
11
+ CONFIG_DIR=" /app/config/${CONFIG_ID} "
12
+
13
+ echo " 🚀 Starting NeMo Guardrails with config from: $CONFIG_DIR (port: $PORT )"
14
+
15
+ # Validate config exists
16
+ if [[ ! -f " $CONFIG_DIR /config.yaml" ]]; then
17
+ echo " ❌ ERROR: config.yaml not found in $CONFIG_DIR "
18
+ exit 1
19
+ fi
20
+
21
+ # Do NOT attempt to create rails.co if missing (ConfigMap is read-only)
22
+ if [[ ! -f " $CONFIG_DIR /rails.co" ]]; then
23
+ echo " ❌ ERROR: rails.co not found in $CONFIG_DIR (ConfigMap is read-only, please provide it)"
24
+ exit 1
25
+ fi
26
+
27
+ echo " ✅ Configuration validated. Starting server..."
28
+ exec poetry run nemoguardrails server \
29
+ --config " /app/config" \
30
+ --port " $PORT " \
31
+ --default-config-id " $CONFIG_ID "
You can’t perform that action at this time.
0 commit comments