-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
54 lines (42 loc) · 1.46 KB
/
Dockerfile
File metadata and controls
54 lines (42 loc) · 1.46 KB
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
52
53
54
FROM python:3.12-slim
# Install system dependencies
RUN apt-get update && apt-get install -y \
build-essential \
curl \
wget \
&& rm -rf /var/lib/apt/lists/*
# Set working directory
WORKDIR /app
# Copy requirements first for better caching
COPY requirements.txt ./
# Install Python dependencies
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r requirements.txt
# Download spaCy models for Presidio
RUN python -m spacy download en_core_web_sm && \
python -m spacy download en_core_web_lg
# Verify Presidio installation and download required models
RUN python -c "from presidio_analyzer import AnalyzerEngine; \
from presidio_anonymizer import AnonymizerEngine; \
print('✅ Presidio installed successfully'); \
analyzer = AnalyzerEngine(); \
print('✅ Presidio Analyzer initialized'); \
anonymizer = AnonymizerEngine(); \
print('✅ Presidio Anonymizer initialized')"
# Copy application code and policy file
COPY app ./app
COPY policy.tool_access.yaml ./
# Create non-root user
RUN useradd --create-home --shell /bin/bash app && \
chown -R app:app /app
USER app
# Expose port
EXPOSE 8080
# Set environment variables
ENV APP_BIND=0.0.0.0:8080
ENV PYTHONPATH=/app
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD curl -f http://localhost:8080/api/v1/health || exit 1
# Run the application
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8080"]