Spaces:
Runtime error
Runtime error
Update Dockerfile
Browse files- Dockerfile +27 -9
Dockerfile
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
FROM python:3.11-slim
|
2 |
|
3 |
-
# Set
|
4 |
-
|
5 |
|
6 |
# Install system dependencies
|
7 |
RUN apt-get update && \
|
@@ -10,22 +10,40 @@ RUN apt-get update && \
|
|
10 |
python3-dev \
|
11 |
&& rm -rf /var/lib/apt/lists/*
|
12 |
|
13 |
-
# Create
|
14 |
ENV VIRTUAL_ENV=/opt/venv
|
15 |
RUN python3 -m venv $VIRTUAL_ENV
|
16 |
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
|
17 |
-
RUN which python
|
18 |
|
19 |
-
#
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
|
22 |
# Install dependencies in virtual environment
|
23 |
-
RUN
|
24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
|
26 |
# Expose the default Chainlit port
|
27 |
EXPOSE 7860
|
28 |
|
29 |
# Command to run the application
|
30 |
-
# CMD . /opt/venv/bin/activate && exec chainlit run app.py --port 8000
|
31 |
CMD ["chainlit", "run", "app.py", "--port", "7860"]
|
|
|
1 |
FROM python:3.11-slim
|
2 |
|
3 |
+
# Set up a new user named "user" with user ID 1000
|
4 |
+
RUN useradd -m -u 1000 user
|
5 |
|
6 |
# Install system dependencies
|
7 |
RUN apt-get update && \
|
|
|
10 |
python3-dev \
|
11 |
&& rm -rf /var/lib/apt/lists/*
|
12 |
|
13 |
+
# Create virtual environment
|
14 |
ENV VIRTUAL_ENV=/opt/venv
|
15 |
RUN python3 -m venv $VIRTUAL_ENV
|
16 |
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
|
|
|
17 |
|
18 |
+
# Switch to the "user" user
|
19 |
+
USER user
|
20 |
+
|
21 |
+
# Set home and PATH
|
22 |
+
ENV HOME=/home/user \
|
23 |
+
PATH=/home/user/.local/bin:$VIRTUAL_ENV/bin:$PATH
|
24 |
+
|
25 |
+
# Set the working directory to the user's home directory
|
26 |
+
WORKDIR $HOME/app
|
27 |
+
|
28 |
+
# Copy requirements first (with correct ownership)
|
29 |
+
COPY --chown=user requirements.txt $HOME/app/requirements.txt
|
30 |
|
31 |
# Install dependencies in virtual environment
|
32 |
+
RUN pip install --no-cache-dir --upgrade pip && \
|
33 |
+
pip install --no-cache-dir --upgrade -r requirements.txt && \
|
34 |
+
pip install -qU chainlit
|
35 |
+
|
36 |
+
# Copy the rest of the application with correct ownership
|
37 |
+
COPY --chown=user . $HOME/app
|
38 |
+
|
39 |
+
# Create content directory for assets (if needed)
|
40 |
+
RUN mkdir -p content
|
41 |
+
|
42 |
+
# If you need to download specific assets, uncomment and modify this line:
|
43 |
+
# ADD --chown=user https://<SOME_ASSET_URL> content/<SOME_ASSET_NAME>
|
44 |
|
45 |
# Expose the default Chainlit port
|
46 |
EXPOSE 7860
|
47 |
|
48 |
# Command to run the application
|
|
|
49 |
CMD ["chainlit", "run", "app.py", "--port", "7860"]
|