Skip to content

Commit 6d5a20c

Browse files
fix: set workdir to models and specify entrypoint explicitly.
* Fix bug with git to fetch models, use wget instead * Fix bug where workdir is kept as /models. Specify entrypoint explicitly.
1 parent 9a77f6f commit 6d5a20c

File tree

2 files changed

+15
-18
lines changed

2 files changed

+15
-18
lines changed

nemoguardrails/library/jailbreak_detection/Dockerfile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ FROM python:3.10-slim
44
# Install git and wget
55
RUN apt-get update && apt-get install -y git gcc g++ python3-dev wget && apt-get clean
66

7+
# Predownload embedding-based jailbreak detection models, set environment variable for path
8+
WORKDIR /models
9+
RUN wget https://huggingface.co/nvidia/NemoGuard-JailbreakDetect/resolve/main/snowflake.pkl
10+
ENV EMBEDDING_CLASSIFIER_PATH=/models
11+
712
# Set working directory
813
WORKDIR /app
914

@@ -21,14 +26,9 @@ ENV JAILBREAK_CHECK_DEVICE=cpu
2126
# Predownload the GPT2 model.
2227
RUN python -c "from transformers import GPT2LMHeadModel, GPT2TokenizerFast; GPT2LMHeadModel.from_pretrained('gpt2-large'); GPT2TokenizerFast.from_pretrained('gpt2-large');"
2328

24-
# Predownload embedding-based jailbreak detection models, set environment variable for path
25-
WORKDIR /models
26-
RUN wget https://huggingface.co/nvidia/NemoGuard-JailbreakDetect/resolve/main/snowflake.pkl
27-
ENV EMBEDDING_CLASSIFIER_PATH=/models
28-
2929
# Expose a port for the server
3030
EXPOSE 1337
3131

3232
# Start the server as the default command
33-
ENTRYPOINT ["/usr/local/bin/python", "server.py"]
33+
ENTRYPOINT ["/usr/local/bin/python", "/app/server.py"]
3434
CMD ["--port=1337"]

nemoguardrails/library/jailbreak_detection/Dockerfile-GPU

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ RUN apt-get install python3 python3-pip python3-dev -y
1010
# Upgrade pip
1111
RUN pip install --no-cache-dir --upgrade pip
1212

13+
# Set the device on which the model should load e.g., "cpu", "cuda:0", etc.
14+
ENV JAILBREAK_CHECK_DEVICE=cuda:0
15+
16+
# Predownload embedding-based jailbreak detection models, set environment variable for path
17+
WORKDIR /models
18+
RUN wget https://huggingface.co/nvidia/NemoGuard-JailbreakDetect/resolve/main/snowflake.pkl
19+
ENV EMBEDDING_CLASSIFIER_PATH=/models
20+
1321
# Set working directory
1422
WORKDIR /app
1523

@@ -24,20 +32,9 @@ COPY . .
2432
# Predownload the GPT2 model.
2533
RUN python3 -c "from transformers import GPT2LMHeadModel, GPT2TokenizerFast; GPT2LMHeadModel.from_pretrained('gpt2-large'); GPT2TokenizerFast.from_pretrained('gpt2-large');"
2634

27-
# Set the device on which the model should load e.g., "cpu", "cuda:0", etc.
28-
ENV JAILBREAK_CHECK_DEVICE=cuda:0
29-
30-
# Predownload embedding-based jailbreak detection models, set environment variable for path
31-
WORKDIR /models
32-
RUN wget https://huggingface.co/nvidia/NemoGuard-JailbreakDetect/resolve/main/snowflake.pkl
33-
ENV EMBEDDING_CLASSIFIER_PATH=/models
34-
35-
# To use nvidia/nv-embedqa-e5-v5 model, uncomment the line below and set your API key
36-
# ENV NVIDIA_API_KEY=<your_api_key>
37-
3835
# Expose a port for the server
3936
EXPOSE 1337
4037

4138
# Start the server as the default command
42-
ENTRYPOINT ["/usr/local/bin/python", "server.py"]
39+
ENTRYPOINT ["/usr/local/bin/python", "/app/server.py"]
4340
CMD ["--port=1337"]

0 commit comments

Comments
 (0)