-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #63 from guardrails-ai/dockerfile
Local Docker Setup
- Loading branch information
Showing
5 changed files
with
114 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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 Flask application. | ||
# You can use whatever production server you want that support Flask. | ||
# 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")' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters