-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
51 lines (37 loc) · 1.47 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
FROM public.ecr.aws/docker/library/python:3.12-slim
# Accept a build arg for the Guardrails token
# We'll add this to the config using the configure command below
# ARG GUARDRAILS_TOKEN
# Create app directory
WORKDIR /app
# print the version just to verify
RUN python3 --version
# start the virtual environment
RUN python3 -m venv /opt/venv
# Enable venv
ENV PATH="/opt/venv/bin:$PATH"
# Install some utilities; you may not need all of these
RUN apt-get update
RUN apt-get install -y git
# Copy the requirements file
COPY requirements*.txt .
# Install app dependencies
# If you use Poetry this step might be different
RUN pip install -r requirements-lock.txt
# Set the directory for nltk data
ENV NLTK_DATA=/opt/nltk_data
# Download punkt data
RUN python -m nltk.downloader -d /opt/nltk_data punkt
# Run the Guardrails configure command to create a .guardrailsrc file
# RUN guardrails configure --enable-metrics --enable-remote-inferencing --token $GUARDRAILS_TOKEN
# Install any validators from the hub you want
RUN guardrails hub install hub://guardrails/valid_length
# Copy the rest over
# We use a .dockerignore to keep unwanted files exluded
COPY . .
EXPOSE 8000
# This is our start command; yours might be different.
# The guardrails-api is a standard FastAPI application.
# You can use whatever production server you want that support FastAPI.
# Here we use gunicorn
CMD gunicorn --bind 0.0.0.0:8000 --timeout=90 --workers=2 'guardrails_api.app:create_app(".env", "sample-config.py")'