LogicGoInfotechSpaces commited on
Commit
408bacf
·
verified ·
1 Parent(s): 4839b27

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +9 -42
Dockerfile CHANGED
@@ -1,67 +1,34 @@
1
  FROM python:3.10-slim
2
 
3
- # Set working directory
4
  WORKDIR /app
5
 
6
  # Install system dependencies
7
  RUN apt-get update && apt-get install -y \
 
8
  libgl1 \
9
  libglib2.0-0 \
10
  libsm6 \
11
  libxext6 \
12
  libxrender-dev \
13
  libgomp1 \
14
- git \
15
  && rm -rf /var/lib/apt/lists/*
16
 
17
- # Copy requirements first for better caching
18
  COPY requirements.txt .
19
 
20
- # Install Python dependencies
21
  RUN pip install --no-cache-dir -r requirements.txt
22
 
23
- # Copy application code
24
  COPY . .
25
 
26
- # Create directories for uploads and results
27
- # Note: /data is already writable in Hugging Face Spaces, no chmod needed
28
- RUN mkdir -p /data/uploads /data/results
29
-
30
- # Handle Firebase credentials from environment variable (for Hugging Face Spaces secrets)
31
- # This allows the credentials to be passed as a secret and written to file at runtime
32
- # Note: Python code will create /data/hf_cache with proper permissions
33
- # Make Firebase credentials writing non-fatal (use || true to continue on error)
34
- RUN echo '#!/bin/sh' > /entrypoint.sh && \
35
- echo 'mkdir -p /tmp/colorize_uploads /tmp/colorize_results /tmp/hf_cache || true' >> /entrypoint.sh && \
36
- echo 'if [ -n "$FIREBASE_CREDENTIALS" ]; then' >> /entrypoint.sh && \
37
- echo ' printf "%s" "$FIREBASE_CREDENTIALS" > /tmp/firebase-adminsdk.json 2>/dev/null || true' >> /entrypoint.sh && \
38
- echo 'fi' >> /entrypoint.sh && \
39
- echo 'exec "$@"' >> /entrypoint.sh && \
40
- chmod +x /entrypoint.sh
41
-
42
- # Expose port (Hugging Face Spaces uses port 7860)
43
  EXPOSE 7860
44
 
45
- # Set environment variables
46
  ENV PYTHONUNBUFFERED=1
47
- ENV BASE_URL=${SPACE_HOST}
48
  ENV PORT=7860
49
- ENV DATA_DIR=/data
50
- ENV OMP_NUM_THREADS=1
51
- ENV HF_HOME=/tmp/hf_cache
52
- ENV TRANSFORMERS_CACHE=/tmp/hf_cache
53
- ENV HUGGINGFACE_HUB_CACHE=/tmp/hf_cache
54
- ENV HF_HUB_CACHE=/tmp/hf_cache
55
- ENV XDG_CACHE_HOME=/tmp/hf_cache
56
- ENV MPLCONFIGDIR=/tmp/matplotlib_config
57
-
58
- # Health check
59
- HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
60
- CMD python -c "import requests; requests.get('http://localhost:7860/health', timeout=5)" || exit 1
61
-
62
- # Set entrypoint
63
- ENTRYPOINT ["/entrypoint.sh"]
64
 
65
- # Run the application (port will be set via environment variable)
66
- # Use main.py with GAN and CCO colorization models
67
- CMD ["sh", "-c", "uvicorn app.main:app --host 0.0.0.0 --port ${PORT:-7860}"]
 
1
  FROM python:3.10-slim
2
 
3
+ # Working directory
4
  WORKDIR /app
5
 
6
  # Install system dependencies
7
  RUN apt-get update && apt-get install -y \
8
+ git \
9
  libgl1 \
10
  libglib2.0-0 \
11
  libsm6 \
12
  libxext6 \
13
  libxrender-dev \
14
  libgomp1 \
 
15
  && rm -rf /var/lib/apt/lists/*
16
 
17
+ # Copy requirements
18
  COPY requirements.txt .
19
 
20
+ # Install python packages
21
  RUN pip install --no-cache-dir -r requirements.txt
22
 
23
+ # Copy project files
24
  COPY . .
25
 
26
+ # Expose HuggingFace port
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  EXPOSE 7860
28
 
29
+ # Environment variables
30
  ENV PYTHONUNBUFFERED=1
 
31
  ENV PORT=7860
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
 
33
+ # Run FastAPI
34
+ CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]