Rajhuggingface4253 commited on
Commit
d94d73d
·
verified ·
1 Parent(s): e3faa5f

Rename Dockerfile to dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile → dockerfile +16 -11
Dockerfile → dockerfile RENAMED
@@ -1,7 +1,7 @@
1
  # Use the official Python slim image
2
  FROM python:3.10-slim-bookworm
3
 
4
- # Set environment variables
5
  ENV DEBIAN_FRONTEND=noninteractive
6
  ENV PYTHONUNBUFFERED=1
7
  ENV PYTHONDONTWRITEBYTECODE=1
@@ -9,7 +9,7 @@ ENV HF_HOME=/app/cache
9
  ENV NUMBA_CACHE_DIR=/app/cache/numba_cache
10
  ENV CUDA_VISIBLE_DEVICES=""
11
 
12
- # Install essential system dependencies as root
13
  RUN apt-get update && apt-get install -y --no-install-recommends \
14
  git \
15
  build-essential \
@@ -22,19 +22,24 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
22
  # Set the working directory
23
  WORKDIR /app
24
 
25
- # ---- START: All Root-level Setup ----
26
- # Create a new user and create/permission all necessary directories at once
27
- RUN useradd --create-home --uid 1000 appuser && \
28
- mkdir -p /app/cache && \
29
- chown -R appuser:appuser /app /app/cache
30
- # ---- END: Root-level Setup ----
31
 
32
- # Switch to the non-root user for the rest of the build
33
  USER appuser
 
 
34
  ENV PATH="/home/appuser/.local/bin:${PATH}"
35
 
36
- # Install Python packages as the non-root user
37
- RUN pip install llama-cpp-python==0.2.71 --no-cache-dir
 
 
 
 
 
 
38
  COPY --chown=appuser:appuser requirements.txt .
39
  RUN pip install --no-cache-dir -r requirements.txt
40
 
 
1
  # Use the official Python slim image
2
  FROM python:3.10-slim-bookworm
3
 
4
+ # Set environment variables to control caching and Python behavior
5
  ENV DEBIAN_FRONTEND=noninteractive
6
  ENV PYTHONUNBUFFERED=1
7
  ENV PYTHONDONTWRITEBYTECODE=1
 
9
  ENV NUMBA_CACHE_DIR=/app/cache/numba_cache
10
  ENV CUDA_VISIBLE_DEVICES=""
11
 
12
+ # Install essential system dependencies
13
  RUN apt-get update && apt-get install -y --no-install-recommends \
14
  git \
15
  build-essential \
 
22
  # Set the working directory
23
  WORKDIR /app
24
 
25
+ # ---- START: Non-Root User Configuration ----
26
+ # Create a new user 'appuser' with UID 1000 and create their home directory
27
+ RUN useradd --create-home --uid 1000 appuser
 
 
 
28
 
29
+ # Switch to the non-root user
30
  USER appuser
31
+
32
+ # ---- Add this line to fix the PATH issue ----
33
  ENV PATH="/home/appuser/.local/bin:${PATH}"
34
 
35
+ # Create the cache directory and set ownership to the new user
36
+ # This needs to run as root, so we'll adjust the Dockerfile structure slightly
37
+ USER root
38
+ RUN mkdir -p /app/cache && chown -R appuser:appuser /app /app/cache
39
+ USER appuser
40
+ # ---- END: Non-Root User Configuration ----
41
+
42
+ # Copy requirements file and install dependencies as the non-root user
43
  COPY --chown=appuser:appuser requirements.txt .
44
  RUN pip install --no-cache-dir -r requirements.txt
45