Spaces:
Sleeping
Sleeping
Ultra-lean build: Surgical copy and pinned dependencies
Browse files- Dockerfile +23 -17
- requirements.txt +9 -9
Dockerfile
CHANGED
|
@@ -1,30 +1,36 @@
|
|
| 1 |
FROM python:3.10-slim
|
| 2 |
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
-
|
| 6 |
-
RUN apt-get update && \
|
| 7 |
-
apt-get clean && \
|
| 8 |
-
rm -rf /var/lib/apt/lists/*
|
| 9 |
|
| 10 |
-
#
|
| 11 |
RUN useradd -m -u 1000 user
|
| 12 |
-
USER user
|
| 13 |
-
ENV HOME=/home/user \
|
| 14 |
-
PATH=/home/user/.local/bin:$PATH \
|
| 15 |
-
PYTHONPATH=/app
|
| 16 |
|
| 17 |
-
# Copy
|
| 18 |
COPY --chown=user requirements.txt .
|
| 19 |
-
RUN pip install --no-cache-dir --
|
|
|
|
| 20 |
|
| 21 |
-
#
|
| 22 |
-
|
| 23 |
|
| 24 |
-
#
|
| 25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
-
#
|
| 28 |
EXPOSE 7860
|
| 29 |
|
| 30 |
# Run API
|
|
|
|
| 1 |
FROM python:3.10-slim
|
| 2 |
|
| 3 |
+
# Set environment variables
|
| 4 |
+
ENV PYTHONDONTWRITEBYTECODE=1 \
|
| 5 |
+
PYTHONUNBUFFERED=1 \
|
| 6 |
+
PYTHONPATH=/app \
|
| 7 |
+
HOME=/home/user
|
| 8 |
|
| 9 |
+
WORKDIR /app
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
+
# Create user
|
| 12 |
RUN useradd -m -u 1000 user
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
+
# Copy and install requirements first
|
| 15 |
COPY --chown=user requirements.txt .
|
| 16 |
+
RUN pip install --no-cache-dir --upgrade pip && \
|
| 17 |
+
pip install --no-cache-dir --user -r requirements.txt
|
| 18 |
|
| 19 |
+
# Add user local bin to path
|
| 20 |
+
ENV PATH="/home/user/.local/bin:${PATH}"
|
| 21 |
|
| 22 |
+
# surgically copy only what is needed
|
| 23 |
+
COPY --chown=user telecom_anomaly/ telecom_anomaly/
|
| 24 |
+
COPY --chown=user config/ config/
|
| 25 |
+
COPY --chown=user main.py .
|
| 26 |
+
|
| 27 |
+
# Create empty directories with right permissions
|
| 28 |
+
RUN mkdir -p data/input data/output data/save_pdf logs data/raw_csv_temp data/output_process_data data/strictly_cleaned_data && \
|
| 29 |
+
chown -R user:user /app
|
| 30 |
+
|
| 31 |
+
USER user
|
| 32 |
|
| 33 |
+
# Expose HF default port
|
| 34 |
EXPOSE 7860
|
| 35 |
|
| 36 |
# Run API
|
requirements.txt
CHANGED
|
@@ -1,14 +1,14 @@
|
|
| 1 |
# Core Analysis
|
| 2 |
-
pandas
|
| 3 |
-
numpy
|
| 4 |
-
scikit-learn
|
| 5 |
-
pdfplumber
|
| 6 |
|
| 7 |
# API
|
| 8 |
-
fastapi
|
| 9 |
-
uvicorn
|
| 10 |
-
python-multipart
|
| 11 |
-
pydantic
|
| 12 |
|
| 13 |
# Export & PDF
|
| 14 |
-
fpdf2
|
|
|
|
| 1 |
# Core Analysis
|
| 2 |
+
pandas==2.0.3
|
| 3 |
+
numpy==1.24.3
|
| 4 |
+
scikit-learn==1.3.0
|
| 5 |
+
pdfplumber==0.10.2
|
| 6 |
|
| 7 |
# API
|
| 8 |
+
fastapi==0.103.1
|
| 9 |
+
uvicorn==0.23.2
|
| 10 |
+
python-multipart==0.0.6
|
| 11 |
+
pydantic==1.10.12
|
| 12 |
|
| 13 |
# Export & PDF
|
| 14 |
+
fpdf2==2.7.4
|