Spaces:
Runtime error
Runtime error
Update Dockerfile
Browse files- Dockerfile +31 -5
Dockerfile
CHANGED
@@ -1,17 +1,43 @@
|
|
|
|
1 |
FROM python:3.11
|
2 |
|
|
|
3 |
RUN useradd -m -u 1000 user
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
USER user
|
|
|
|
|
5 |
ENV PATH="/home/user/.local/bin:$PATH"
|
|
|
6 |
|
|
|
7 |
WORKDIR /app
|
8 |
|
9 |
-
|
10 |
-
|
11 |
-
RUN
|
12 |
-
RUN sudo apt install python3-pypdf2
|
13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
COPY --chown=user . /app
|
|
|
|
|
15 |
EXPOSE 7860
|
16 |
|
17 |
-
|
|
|
|
1 |
+
# Start with the base Python 3.11 image
|
2 |
FROM python:3.11
|
3 |
|
4 |
+
# Create a new user and set permissions
|
5 |
RUN useradd -m -u 1000 user
|
6 |
+
|
7 |
+
# Install required system packages using apt-get
|
8 |
+
RUN apt-get update && apt-get install -y \
|
9 |
+
curl \
|
10 |
+
python3-pip \
|
11 |
+
build-essential \
|
12 |
+
libssl-dev \
|
13 |
+
libffi-dev \
|
14 |
+
cargo \
|
15 |
+
&& rm -rf /var/lib/apt/lists/*
|
16 |
+
|
17 |
+
# Switch to the non-root user
|
18 |
USER user
|
19 |
+
|
20 |
+
# Set up environment variables
|
21 |
ENV PATH="/home/user/.local/bin:$PATH"
|
22 |
+
ENV VIRTUAL_ENV=/home/packages/.venv
|
23 |
|
24 |
+
# Set the working directory
|
25 |
WORKDIR /app
|
26 |
|
27 |
+
# Add the install script and run it
|
28 |
+
ADD https://astral.sh/uv/install.sh /install.sh
|
29 |
+
RUN chmod +x /install.sh && /install.sh && rm /install.sh
|
|
|
30 |
|
31 |
+
# Copy requirements and install Python dependencies
|
32 |
+
COPY ./requirements.txt .
|
33 |
+
RUN /root/.cargo/bin/uv venv /home/packages/.venv
|
34 |
+
RUN /root/.cargo/bin/uv pip install --no-cache-dir -r requirements.txt
|
35 |
+
|
36 |
+
# Copy the application code to the working directory
|
37 |
COPY --chown=user . /app
|
38 |
+
|
39 |
+
# Expose the port the app runs on
|
40 |
EXPOSE 7860
|
41 |
|
42 |
+
# Define the default command
|
43 |
+
CMD ["python", "app.py"]
|