Spaces:
Running
Running
Update Dockerfile
Browse files- Dockerfile +9 -8
Dockerfile
CHANGED
@@ -4,16 +4,17 @@ FROM python:3.11-slim
|
|
4 |
# Set working directory inside the container
|
5 |
WORKDIR /app
|
6 |
|
7 |
-
# Create a non-root user
|
|
|
8 |
RUN useradd -m -u 1000 appuser
|
9 |
|
10 |
-
# Create the saved_models directory
|
11 |
RUN mkdir -p /app/saved_models && chown -R appuser:appuser /app
|
12 |
|
13 |
-
# Copy requirements.txt
|
14 |
COPY requirements.txt .
|
15 |
|
16 |
-
# Install system dependencies
|
17 |
RUN apt-get update && apt-get install -y \
|
18 |
build-essential \
|
19 |
libatlas-base-dev \
|
@@ -23,16 +24,16 @@ RUN apt-get update && apt-get install -y \
|
|
23 |
# Install Python dependencies
|
24 |
RUN pip install --no-cache-dir -r requirements.txt
|
25 |
|
26 |
-
# Copy the entire application code
|
27 |
COPY . .
|
28 |
|
29 |
-
# Set ownership
|
30 |
RUN chown -R appuser:appuser /app
|
31 |
|
32 |
-
# Switch to non-root user
|
33 |
USER appuser
|
34 |
|
35 |
-
# Expose port
|
36 |
EXPOSE 7860
|
37 |
|
38 |
# Command to run the Flask app
|
|
|
4 |
# Set working directory inside the container
|
5 |
WORKDIR /app
|
6 |
|
7 |
+
# Create a non-root user to match Hugging Face Spaces' setup
|
8 |
+
# UID 1000 is commonly used in Spaces, but this may vary
|
9 |
RUN useradd -m -u 1000 appuser
|
10 |
|
11 |
+
# Create the saved_models directory and set ownership to appuser
|
12 |
RUN mkdir -p /app/saved_models && chown -R appuser:appuser /app
|
13 |
|
14 |
+
# Copy requirements.txt to the working directory
|
15 |
COPY requirements.txt .
|
16 |
|
17 |
+
# Install system dependencies (for faiss, torch, etc.)
|
18 |
RUN apt-get update && apt-get install -y \
|
19 |
build-essential \
|
20 |
libatlas-base-dev \
|
|
|
24 |
# Install Python dependencies
|
25 |
RUN pip install --no-cache-dir -r requirements.txt
|
26 |
|
27 |
+
# Copy the entire application code and datasets to the container
|
28 |
COPY . .
|
29 |
|
30 |
+
# Set ownership of all files to appuser
|
31 |
RUN chown -R appuser:appuser /app
|
32 |
|
33 |
+
# Switch to the non-root user
|
34 |
USER appuser
|
35 |
|
36 |
+
# Expose the port your Flask app will run on (7860 as specified in app.py)
|
37 |
EXPOSE 7860
|
38 |
|
39 |
# Command to run the Flask app
|