Naman712 commited on
Commit
8f84cc1
·
verified ·
1 Parent(s): 42951b9

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +6 -10
Dockerfile CHANGED
@@ -1,33 +1,29 @@
1
  # Use python:3.9-slim-bookworm to ensure stable Debian packages
2
  FROM python:3.9-slim-bookworm
3
 
4
- # 1. Install system dependencies as ROOT
5
- # We use 'libgl1' and 'libglib2.0-0' which are the modern replacements
6
  RUN apt-get update && apt-get install -y \
7
  libgl1 \
8
  libglib2.0-0 \
 
9
  && rm -rf /var/lib/apt/lists/*
10
 
11
- # 2. Create the user and the app directory with correct permissions
12
  RUN useradd -m -u 1000 user
13
-
14
- # Create /app directory and give 'user' ownership
15
- # This MUST be done as root before switching users
16
  RUN mkdir -p /app && chown user:user /app
17
 
18
- # 3. Switch to the non-root user
19
  USER user
20
  ENV PATH="/home/user/.local/bin:$PATH"
21
 
22
- # 4. Set working directory (now owned by 'user')
23
  WORKDIR /app
24
 
25
  # 5. Install Python dependencies
26
- # Copy requirements first to leverage Docker cache
27
  COPY --chown=user ./requirements.txt requirements.txt
28
  RUN pip install --no-cache-dir --upgrade -r requirements.txt
29
 
30
- # 6. Copy the rest of the application
31
  COPY --chown=user . /app
32
 
33
  # 7. Start the application
 
1
  # Use python:3.9-slim-bookworm to ensure stable Debian packages
2
  FROM python:3.9-slim-bookworm
3
 
4
+ # 1. Install system dependencies (Poppler is required for PDF)
 
5
  RUN apt-get update && apt-get install -y \
6
  libgl1 \
7
  libglib2.0-0 \
8
+ poppler-utils \
9
  && rm -rf /var/lib/apt/lists/*
10
 
11
+ # 2. Set up user permissions (Crucial for Spaces)
12
  RUN useradd -m -u 1000 user
 
 
 
13
  RUN mkdir -p /app && chown user:user /app
14
 
15
+ # 3. Switch to non-root user
16
  USER user
17
  ENV PATH="/home/user/.local/bin:$PATH"
18
 
19
+ # 4. Set working directory
20
  WORKDIR /app
21
 
22
  # 5. Install Python dependencies
 
23
  COPY --chown=user ./requirements.txt requirements.txt
24
  RUN pip install --no-cache-dir --upgrade -r requirements.txt
25
 
26
+ # 6. Copy application code
27
  COPY --chown=user . /app
28
 
29
  # 7. Start the application