Skip to content

Commit 537ed09

Browse files
committed
add dockerfile for running locally, update docker compose
1 parent af02055 commit 537ed09

File tree

4 files changed

+111
-59
lines changed

4 files changed

+111
-59
lines changed

Dockerfile

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
FROM public.ecr.aws/docker/library/python:3.12-slim
2+
3+
# Accept a build arg for the Guardrails token
4+
# We'll add this to the config using the configure command below
5+
# ARG GUARDRAILS_TOKEN
6+
7+
# Create app directory
8+
WORKDIR /app
9+
10+
# print the version just to verify
11+
RUN python3 --version
12+
# start the virtual environment
13+
RUN python3 -m venv /opt/venv
14+
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
21+
22+
# Copy the requirements file
23+
COPY requirements*.txt .
24+
25+
# Install app dependencies
26+
# If you use Poetry this step might be different
27+
RUN pip install -r requirements-lock.txt
28+
29+
# Set the directory for nltk data
30+
ENV NLTK_DATA=/opt/nltk_data
31+
32+
# Download punkt data
33+
RUN python -m nltk.downloader -d /opt/nltk_data punkt
34+
35+
# Run the Guardrails configure command to create a .guardrailsrc file
36+
# RUN guardrails configure --enable-metrics --enable-remote-inferencing --token $GUARDRAILS_TOKEN
37+
38+
# Install any validators from the hub you want
39+
RUN guardrails hub install hub://guardrails/valid_length
40+
41+
# Copy the rest over
42+
# We use a .dockerignore to keep unwanted files exluded
43+
COPY . .
44+
45+
EXPOSE 8000
46+
47+
# This is our start command; yours might be different.
48+
# The guardrails-api is a standard Flask application.
49+
# You can use whatever production server you want that support Flask.
50+
# 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")'

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ install-dev:
77
pip install ".[dev]";
88

99
lock:
10-
pip freeze --exclude guardrails-api-client > requirements-lock.txt
10+
pip freeze --exclude guardrails-api > requirements-lock.txt
1111

1212
install-lock:
1313
pip install -r requirements-lock.txt

compose.yml

+20-20
Original file line numberDiff line numberDiff line change
@@ -33,29 +33,29 @@ services:
3333
image: guardrails-api:latest
3434
build:
3535
context: .
36-
dockerfile: Dockerfile.dev
36+
dockerfile: Dockerfile
3737
args:
3838
PORT: "8000"
3939
ports:
4040
- "8000:8000"
4141
environment:
42-
APP_ENVIRONMENT: local
43-
AWS_PROFILE: dev
44-
AWS_DEFAULT_REGION: us-east-1
45-
PGPORT: 5432
46-
PGDATABASE: postgres
47-
PGHOST: postgres
48-
PGUSER: ${PGUSER:-postgres}
49-
PGPASSWORD: ${PGPASSWORD:-changeme}
42+
# APP_ENVIRONMENT: local
43+
# AWS_PROFILE: dev
44+
# AWS_DEFAULT_REGION: us-east-1
45+
# PGPORT: 5432
46+
# PGDATABASE: postgres
47+
# PGHOST: postgres
48+
# PGUSER: ${PGUSER:-postgres}
49+
# PGPASSWORD: ${PGPASSWORD:-changeme}
5050
NLTK_DATA: /opt/nltk_data
51-
OTEL_PYTHON_TRACER_PROVIDER: sdk_tracer_provider
52-
OTEL_SERVICE_NAME: guardrails-api
53-
OTEL_EXPORTER_OTLP_ENDPOINT: http://otel-collector:4317
54-
OTEL_TRACES_EXPORTER: otlp #,console
55-
OTEL_INSTRUMENTATION_HTTP_CAPTURE_HEADERS_SERVER_REQUEST: "Accept-Encoding,User-Agent,Referer"
56-
OTEL_INSTRUMENTATION_HTTP_CAPTURE_HEADERS_SERVER_RESPONSE: "Last-Modified,Content-Type"
57-
OTEL_METRICS_EXPORTER: otlp #,console
58-
OTEL_EXPORTER_OTLP_PROTOCOL: grpc
51+
# OTEL_PYTHON_TRACER_PROVIDER: sdk_tracer_provider
52+
# OTEL_SERVICE_NAME: guardrails-api
53+
# OTEL_EXPORTER_OTLP_ENDPOINT: http://otel-collector:4317
54+
# OTEL_TRACES_EXPORTER: otlp #,console
55+
# OTEL_INSTRUMENTATION_HTTP_CAPTURE_HEADERS_SERVER_REQUEST: "Accept-Encoding,User-Agent,Referer"
56+
# OTEL_INSTRUMENTATION_HTTP_CAPTURE_HEADERS_SERVER_RESPONSE: "Last-Modified,Content-Type"
57+
# OTEL_METRICS_EXPORTER: otlp #,console
58+
# OTEL_EXPORTER_OTLP_PROTOCOL: grpc
5959
# # Disable logging for now to reduce noise
6060
# OTEL_LOGS_EXPORTER: otlp,console
6161
# OTEL_PYTHON_LOG_CORRELATION: true
@@ -68,9 +68,9 @@ services:
6868
# OTEL_EXPORTER_OTLP_METRICS_ENDPOINT: http://otel-collector:4317
6969
# OTEL_EXPORTER_OTLP_LOGS_ENDPOINT: http://otel-collector:4317
7070
# OTEL_PYTHON_LOG_FORMAT: "%(msg)s [span_id=%(span_id)s]"
71-
depends_on:
72-
- postgres
73-
- otel-collector
71+
# depends_on:
72+
# - postgres
73+
# - otel-collector
7474
opensearch-node1:
7575
profiles: ["all", "otel", "infra"]
7676
image: opensearchproject/opensearch:latest

requirements-lock.txt

+39-38
Original file line numberDiff line numberDiff line change
@@ -5,42 +5,40 @@ anyio==4.4.0
55
arrow==1.3.0
66
attrs==23.2.0
77
blinker==1.8.2
8-
boto3==1.34.132
9-
botocore==1.34.132
8+
boto3==1.34.149
9+
botocore==1.34.149
1010
cachelib==0.9.0
1111
certifi==2024.7.4
12-
cffi==1.16.0
1312
charset-normalizer==3.3.2
1413
click==8.1.7
1514
colorama==0.4.6
1615
coloredlogs==15.0.1
17-
cryptography==42.0.8
16+
coverage==7.6.0
1817
Deprecated==1.2.14
1918
distro==1.9.0
20-
Faker==25.9.1
19+
Faker==25.9.2
2120
filelock==3.15.4
2221
Flask==3.0.3
2322
Flask-Caching==2.3.0
2423
Flask-Cors==4.0.1
2524
Flask-SQLAlchemy==3.1.1
2625
fqdn==1.5.1
2726
frozenlist==1.4.1
28-
fsspec==2024.6.0
27+
fsspec==2024.6.1
2928
googleapis-common-protos==1.63.2
3029
griffe==0.36.9
31-
grpcio==1.64.1
32-
guardrails-ai==0.5.0a2
33-
guardrails-api @ file:///Users/calebcourier/Projects/gr-mono/guardrails-cdk/guardrails-api
34-
guardrails-api-client==0.3.8
30+
grpcio==1.65.1
31+
guardrails-ai==0.5.1
32+
guardrails-api-client==0.3.9
3533
gunicorn==22.0.0
3634
h11==0.14.0
3735
httpcore==1.0.5
3836
httpx==0.27.0
39-
huggingface-hub==0.23.4
37+
huggingface-hub==0.24.2
4038
humanfriendly==10.0
4139
idna==3.7
42-
ijson==3.3.0
43-
importlib_metadata==7.1.0
40+
importlib_metadata==8.0.0
41+
iniconfig==2.0.0
4442
isoduration==20.11.0
4543
itsdangerous==2.2.0
4644
Jinja2==3.1.4
@@ -49,39 +47,41 @@ joblib==1.4.2
4947
jsonpatch==1.33
5048
jsonpointer==3.0.0
5149
jsonref==1.1.0
52-
jsonschema==4.22.0
50+
jsonschema==4.23.0
5351
jsonschema-specifications==2023.12.1
54-
jwt==1.3.1
55-
langchain-core==0.2.9
56-
langsmith==0.1.82
57-
litellm==1.40.25
52+
langchain-core==0.2.23
53+
langsmith==0.1.93
54+
litellm==1.42.3
5855
lxml==4.9.4
5956
markdown-it-py==3.0.0
6057
MarkupSafe==2.1.5
6158
mdurl==0.1.2
6259
multidict==6.0.5
6360
nltk==3.8.1
64-
openai==1.35.3
65-
opentelemetry-api==1.25.0
66-
opentelemetry-exporter-otlp-proto-common==1.25.0
67-
opentelemetry-exporter-otlp-proto-grpc==1.25.0
68-
opentelemetry-exporter-otlp-proto-http==1.25.0
69-
opentelemetry-instrumentation==0.46b0
70-
opentelemetry-instrumentation-flask==0.46b0
71-
opentelemetry-instrumentation-wsgi==0.46b0
72-
opentelemetry-proto==1.25.0
73-
opentelemetry-sdk==1.25.0
74-
opentelemetry-semantic-conventions==0.46b0
75-
opentelemetry-util-http==0.46b0
76-
orjson==3.10.5
61+
openai==1.37.1
62+
opentelemetry-api==1.26.0
63+
opentelemetry-exporter-otlp-proto-common==1.26.0
64+
opentelemetry-exporter-otlp-proto-grpc==1.26.0
65+
opentelemetry-exporter-otlp-proto-http==1.26.0
66+
opentelemetry-instrumentation==0.47b0
67+
opentelemetry-instrumentation-flask==0.47b0
68+
opentelemetry-instrumentation-wsgi==0.47b0
69+
opentelemetry-proto==1.26.0
70+
opentelemetry-sdk==1.26.0
71+
opentelemetry-semantic-conventions==0.47b0
72+
opentelemetry-util-http==0.47b0
73+
orjson==3.10.6
7774
packaging==24.1
78-
protobuf==4.25.3
75+
pluggy==1.5.0
76+
protobuf==4.25.4
7977
psycopg2-binary==2.9.9
80-
pycparser==2.22
81-
pydantic==2.7.4
82-
pydantic_core==2.18.4
78+
pydantic==2.8.2
79+
pydantic_core==2.20.1
8380
pydash==7.0.7
8481
Pygments==2.18.0
82+
PyJWT==2.8.0
83+
pytest==8.3.2
84+
pytest-mock==3.14.0
8585
python-dateutil==2.9.0.post0
8686
python-dotenv==1.0.1
8787
PyYAML==6.0.1
@@ -91,15 +91,16 @@ requests==2.32.3
9191
rfc3339-validator==0.1.4
9292
rfc3987==1.3.8
9393
rich==13.7.1
94-
rpds-py==0.18.1
94+
rpds-py==0.19.1
9595
rstr==3.2.2
96+
ruff==0.5.5
9697
s3transfer==0.10.2
97-
setuptools==70.1.0
98+
setuptools==71.1.0
9899
shellingham==1.5.4
99100
six==1.16.0
100101
sniffio==1.3.1
101102
SQLAlchemy==2.0.31
102-
tenacity==8.4.2
103+
tenacity==8.5.0
103104
tiktoken==0.7.0
104105
tokenizers==0.19.1
105106
tqdm==4.66.4

0 commit comments

Comments
 (0)