Skip to content

Commit b21d4b5

Browse files
fixes for dockerfile
1 parent 3877ac7 commit b21d4b5

File tree

1 file changed

+25
-15
lines changed

1 file changed

+25
-15
lines changed

Dockerfile

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,32 @@
1-
FROM public.ecr.aws/docker/library/python:3.12-slim
1+
FROM python:3.12-slim
22

33
# Accept a build arg for the Guardrails token
44
# We'll add this to the config using the configure command below
5-
# ARG GUARDRAILS_TOKEN
5+
ARG GUARDRAILS_TOKEN
66

77
# Create app directory
88
WORKDIR /app
99

10+
# Enable venv
11+
ENV PATH="/opt/venv/bin:$PATH"
12+
13+
# Set the directory for nltk data
14+
ENV NLTK_DATA=/opt/nltk_data
15+
16+
# Set env vars for server
17+
ENV GR_CONFIG_FILE_PATH="sample-config.py"
18+
ENV GR_ENV_FILE=".env"
19+
ENV PORT=8000
20+
1021
# print the version just to verify
1122
RUN python3 --version
1223
# start the virtual environment
1324
RUN python3 -m venv /opt/venv
1425

15-
# Enable venv
16-
ENV PATH="/opt/venv/bin:$PATH"
17-
18-
# Install some utilities; you may not need all of these
19-
RUN apt-get update
20-
RUN apt-get install -y git
26+
# Install some utilities
27+
RUN apt-get update && \
28+
apt-get install -y git pkg-config curl gcc g++ && \
29+
rm -rf /var/lib/apt/lists/*
2130

2231
# Copy the requirements file
2332
COPY requirements*.txt .
@@ -26,26 +35,27 @@ COPY requirements*.txt .
2635
# If you use Poetry this step might be different
2736
RUN pip install -r requirements-lock.txt
2837

29-
# Set the directory for nltk data
30-
ENV NLTK_DATA=/opt/nltk_data
31-
3238
# Download punkt data
3339
RUN python -m nltk.downloader -d /opt/nltk_data punkt
3440

3541
# Run the Guardrails configure command to create a .guardrailsrc file
36-
# RUN guardrails configure --enable-metrics --enable-remote-inferencing --token $GUARDRAILS_TOKEN
42+
RUN guardrails configure --enable-metrics --enable-remote-inferencing --token $GUARDRAILS_TOKEN
3743

3844
# Install any validators from the hub you want
39-
RUN guardrails hub install hub://guardrails/valid_length
45+
RUN guardrails hub install hub://guardrails/detect_pii --no-install-local-models && \
46+
guardrails hub install hub://guardrails/competitor_check --no-install-local-models
47+
48+
# Fetch AWS RDS cert
49+
RUN curl https://truststore.pki.rds.amazonaws.com/global/global-bundle.pem -o ./global-bundle.pem
4050

4151
# Copy the rest over
4252
# We use a .dockerignore to keep unwanted files exluded
4353
COPY . .
4454

45-
EXPOSE 8000
55+
EXPOSE ${PORT}
4656

4757
# This is our start command; yours might be different.
4858
# The guardrails-api is a standard FastAPI application.
4959
# You can use whatever production server you want that support FastAPI.
5060
# Here we use gunicorn
51-
CMD gunicorn --bind 0.0.0.0:8000 --timeout=90 --workers=2 'guardrails_api.app:create_app(".env", "sample-config.py")'
61+
CMD uvicorn --factory 'guardrails_api.app:create_app' --host 0.0.0.0 --port ${PORT} --timeout-keep-alive=90 --workers=4

0 commit comments

Comments
 (0)