winsweb commited on
Commit
9630604
·
1 Parent(s): 2a31c90

Optimize: Reduce upload size and use standard HF Dockerfile

Browse files
Files changed (2) hide show
  1. .dockerignore +9 -0
  2. Dockerfile +13 -15
.dockerignore CHANGED
@@ -19,3 +19,12 @@ error.txt
19
  tests/
20
  .ipynb_checkpoints/
21
  .cache/
 
 
 
 
 
 
 
 
 
 
19
  tests/
20
  .ipynb_checkpoints/
21
  .cache/
22
+ node_modules/
23
+ *.exe
24
+ *.dll
25
+ *.so
26
+ *.bak
27
+ *.tmp
28
+ *.log
29
+ .DS_Store
30
+ Thumbs.db
Dockerfile CHANGED
@@ -1,33 +1,31 @@
1
- # Use a newer Python version for better wheel support
2
  FROM python:3.10-slim
3
 
4
- # Install system dependencies (No Java needed for pdfplumber)
 
 
5
  RUN apt-get update && \
6
  apt-get clean && \
7
  rm -rf /var/lib/apt/lists/*
8
 
9
- # Set up a non-root user (Hugging Face standard)
10
  RUN useradd -m -u 1000 user
11
  USER user
12
  ENV HOME=/home/user \
13
- PATH=/home/user/.local/bin:$PATH
14
- WORKDIR $HOME/app
15
-
16
- # Set PYTHONPATH to ensure imports work correctly
17
- ENV PYTHONPATH=$HOME/app
18
 
19
- # Copy requirements first to leverage Docker cache
20
  COPY --chown=user requirements.txt .
21
- RUN pip install --no-cache-dir --user -r requirements.txt
22
 
23
- # Copy the rest of the application
24
  COPY --chown=user . .
25
 
26
- # Pre-create directories and set permissions (important for the 'user' account)
27
  RUN mkdir -p data/input data/output data/save_pdf logs data/raw_csv_temp data/output_process_data data/strictly_cleaned_data
28
 
29
- # Expose port 7860 (Hugging Face default)
30
  EXPOSE 7860
31
 
32
- # Command to run the API
33
- CMD ["uvicorn", "telecom_anomaly.api:app", "--host", "0.0.0.0", "--port", "7860"]
 
 
1
  FROM python:3.10-slim
2
 
3
+ WORKDIR /app
4
+
5
+ # Install system dependencies
6
  RUN apt-get update && \
7
  apt-get clean && \
8
  rm -rf /var/lib/apt/lists/*
9
 
10
+ # Set up user with UID 1000 (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
+ PYTHONPATH=/app
 
 
 
16
 
17
+ # Copy requirements first for better caching
18
  COPY --chown=user requirements.txt .
19
+ RUN pip install --no-cache-dir --user --upgrade -r requirements.txt
20
 
21
+ # Copy the application code
22
  COPY --chown=user . .
23
 
24
+ # Ensure app directories exist and are writable
25
  RUN mkdir -p data/input data/output data/save_pdf logs data/raw_csv_temp data/output_process_data data/strictly_cleaned_data
26
 
27
+ # Use 0.0.0.0 and 7860
28
  EXPOSE 7860
29
 
30
+ # Run API
31
+ CMD ["python3", "-m", "uvicorn", "telecom_anomaly.api:app", "--host", "0.0.0.0", "--port", "7860"]