mike23415 commited on
Commit
f3285b1
·
verified ·
1 Parent(s): 85c98d3

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +12 -11
Dockerfile CHANGED
@@ -1,10 +1,6 @@
1
  FROM python:3.9-slim
2
 
3
- # Create cache directory with proper permissions
4
- RUN mkdir -p /app/.cache && \
5
- chmod 777 /app/.cache
6
-
7
- # Install system dependencies
8
  RUN apt-get update && \
9
  apt-get install -y \
10
  gcc \
@@ -12,24 +8,29 @@ RUN apt-get update && \
12
  wkhtmltopdf \
13
  xvfb \
14
  fonts-liberation \
15
- fonts-dejavu \
16
  && rm -rf /var/lib/apt/lists/*
17
 
 
 
 
 
18
  WORKDIR /app
19
 
20
- # Set environment variables for Hugging Face
21
  ENV TRANSFORMERS_CACHE=/app/.cache \
22
  HF_DATASETS_CACHE=/app/.cache \
23
  XDG_CACHE_HOME=/app/.cache
24
 
25
- # Install Python dependencies
26
  COPY requirements.txt .
27
- RUN pip install --no-cache-dir -r requirements.txt --mkdir
28
 
29
- # Test model download with proper cache
30
  RUN python -c "from transformers import GPT2LMHeadModel; \
31
- GPT2LMHeadModel.from_pretrained('gpt2-medium', local_files_only=False)"
32
 
33
  COPY . .
34
 
 
 
35
  CMD ["gunicorn", "--bind", "0.0.0.0:5000", "--timeout", "600", "app:app"]
 
1
  FROM python:3.9-slim
2
 
3
+ # System dependencies
 
 
 
 
4
  RUN apt-get update && \
5
  apt-get install -y \
6
  gcc \
 
8
  wkhtmltopdf \
9
  xvfb \
10
  fonts-liberation \
 
11
  && rm -rf /var/lib/apt/lists/*
12
 
13
+ # Create cache directory with proper permissions
14
+ RUN mkdir -p /app/.cache && \
15
+ chown -R 1000:1000 /app/.cache
16
+
17
  WORKDIR /app
18
 
19
+ # Set environment variables
20
  ENV TRANSFORMERS_CACHE=/app/.cache \
21
  HF_DATASETS_CACHE=/app/.cache \
22
  XDG_CACHE_HOME=/app/.cache
23
 
24
+ # Install Python requirements
25
  COPY requirements.txt .
26
+ RUN pip install --no-cache-dir -r requirements.txt
27
 
28
+ # Verify model download
29
  RUN python -c "from transformers import GPT2LMHeadModel; \
30
+ GPT2LMHeadModel.from_pretrained('gpt2-medium', use_safetensors=True)"
31
 
32
  COPY . .
33
 
34
+ # Run as non-root user
35
+ USER 1000
36
  CMD ["gunicorn", "--bind", "0.0.0.0:5000", "--timeout", "600", "app:app"]