1+ FROM python:3.11-slim
2+
3+ ARG GUARDRAILS_TOKEN
4+ ARG GUARDRAILS_TEMPLATE="guard-template.json"
5+
6+ # Set environment variables to avoid writing .pyc files and to unbuffer Python output
7+ ENV PYTHONDONTWRITEBYTECODE=1
8+ ENV PYTHONUNBUFFERED=1
9+ ENV LOGLEVEL="DEBUG"
10+ ENV GUARDRAILS_LOG_LEVEL="DEBUG"
11+ ENV APP_ENVIRONMENT="production"
12+ ENV GUARDRAILS_TEMPLATE=$GUARDRAILS_TEMPLATE
13+
14+ WORKDIR /app
15+
16+ # Install Git and necessary dependencies
17+ RUN apt-get update && \
18+ apt-get install -y make git curl gcc jq pipx && \
19+ apt-get clean && \
20+ rm -rf /var/lib/apt/lists/*
21+
22+ RUN pipx install poetry
23+
24+ # Ensure poetry is available in the PATH
25+ ENV PATH="/root/.local/bin:$PATH"
26+
27+ # Copy the entrypoint script
28+ COPY /server_ci/entry.sh /app/entry.sh
29+ COPY ../ /app/guardrails
30+
31+ # Install guardrails, the guardrails API, and gunicorn
32+ # openai optional. only used for integration testing
33+ RUN pip install "gunicorn" "guardrails-api"
34+
35+ WORKDIR /app/guardrails
36+
37+ RUN poetry install
38+
39+ RUN pip install ./
40+
41+ RUN guardrails configure --enable-metrics --enable-remote-inferencing --token $GUARDRAILS_TOKEN
42+
43+ # bring in base template
44+ COPY /server_ci/$GUARDRAILS_TEMPLATE /app/$GUARDRAILS_TEMPLATE
45+
46+ # Install Hub Deps and create config.py
47+ RUN guardrails create --template /app/$GUARDRAILS_TEMPLATE
48+
49+
50+ RUN cp -r /usr/local/lib/python3.11/site-packages/guardrails/hub/* /app/guardrails/guardrails/hub
51+
52+ # Expose port 8000 for the application
53+ EXPOSE 8000
54+
55+ # Command to start the Gunicorn server with specified settings
56+ CMD ["/bin/bash" , "/app/entry.sh" ]
0 commit comments