Spaces:
Sleeping
Sleeping
Deploy FastAPI on Hugging Face
Browse files- Dockerfile +16 -12
- requirements.txt +0 -5
Dockerfile
CHANGED
|
@@ -1,26 +1,30 @@
|
|
| 1 |
-
# Use
|
| 2 |
-
FROM python:3.
|
| 3 |
|
| 4 |
-
# Install Java Runtime
|
| 5 |
RUN apt-get update && \
|
| 6 |
-
apt-get install -y --no-install-recommends
|
| 7 |
apt-get clean && \
|
| 8 |
rm -rf /var/lib/apt/lists/*
|
| 9 |
|
| 10 |
-
# Set
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
# Set PYTHONPATH to ensure imports work correctly
|
| 14 |
-
ENV PYTHONPATH=/app
|
| 15 |
|
| 16 |
-
# Copy requirements
|
| 17 |
-
COPY requirements.txt .
|
| 18 |
-
RUN pip install --no-cache-dir -r requirements.txt
|
| 19 |
|
| 20 |
# Copy the rest of the application
|
| 21 |
-
COPY . .
|
| 22 |
|
| 23 |
-
# Create necessary directories
|
| 24 |
RUN mkdir -p data/raw_csv_temp data/output_process_data data/strictly_cleaned_data data/output data/save_pdf logs
|
| 25 |
|
| 26 |
# Expose port 7860 (Hugging Face default)
|
|
|
|
| 1 |
+
# Use a newer Python version for better wheel support
|
| 2 |
+
FROM python:3.10-slim
|
| 3 |
|
| 4 |
+
# Install a LIGHTER Java Runtime (Headless is much faster to install)
|
| 5 |
RUN apt-get update && \
|
| 6 |
+
apt-get install -y --no-install-recommends openjdk-17-jre-headless && \
|
| 7 |
apt-get clean && \
|
| 8 |
rm -rf /var/lib/apt/lists/*
|
| 9 |
|
| 10 |
+
# Set up a non-root user (Hugging Face standard)
|
| 11 |
+
RUN useradd -m -u 1000 user
|
| 12 |
+
USER user
|
| 13 |
+
ENV HOME=/home/user \
|
| 14 |
+
PATH=/home/user/.local/bin:$PATH
|
| 15 |
+
WORKDIR $HOME/app
|
| 16 |
|
| 17 |
# Set PYTHONPATH to ensure imports work correctly
|
| 18 |
+
ENV PYTHONPATH=$HOME/app
|
| 19 |
|
| 20 |
+
# Copy requirements first to leverage Docker cache
|
| 21 |
+
COPY --chown=user requirements.txt .
|
| 22 |
+
RUN pip install --no-cache-dir --user -r requirements.txt
|
| 23 |
|
| 24 |
# Copy the rest of the application
|
| 25 |
+
COPY --chown=user . .
|
| 26 |
|
| 27 |
+
# Create necessary directories
|
| 28 |
RUN mkdir -p data/raw_csv_temp data/output_process_data data/strictly_cleaned_data data/output data/save_pdf logs
|
| 29 |
|
| 30 |
# Expose port 7860 (Hugging Face default)
|
requirements.txt
CHANGED
|
@@ -16,8 +16,3 @@ fpdf2>=2.7.0
|
|
| 16 |
# Visualization (if needed for exports)
|
| 17 |
matplotlib>=3.4.0
|
| 18 |
seaborn>=0.11.0
|
| 19 |
-
|
| 20 |
-
# Development
|
| 21 |
-
pytest>=6.2.0
|
| 22 |
-
black>=21.0.0
|
| 23 |
-
flake8>=3.9.0
|
|
|
|
| 16 |
# Visualization (if needed for exports)
|
| 17 |
matplotlib>=3.4.0
|
| 18 |
seaborn>=0.11.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|