Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +21 -18
Dockerfile
CHANGED
@@ -1,29 +1,32 @@
|
|
1 |
-
|
2 |
-
FROM python:3.9-slim
|
3 |
|
4 |
-
# Set
|
5 |
-
WORKDIR /
|
6 |
|
7 |
-
|
8 |
-
COPY requirements.txt .
|
9 |
|
10 |
-
|
11 |
-
RUN apt-get update && apt-get install -y git && \
|
12 |
-
pip install torch && \
|
13 |
-
pip install -r requirements.txt
|
14 |
|
15 |
-
#
|
16 |
-
|
17 |
-
ENV OPENAI_API_KEY=your_openai_api_key_here
|
18 |
|
19 |
-
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
|
22 |
# Copy the rest of the application code into the container
|
23 |
-
COPY .
|
|
|
|
|
|
|
24 |
|
25 |
# Expose the port the app runs on
|
26 |
EXPOSE 8000
|
27 |
|
28 |
-
# Run the application
|
29 |
-
CMD ["
|
|
|
1 |
+
FROM python:3.9
|
|
|
2 |
|
3 |
+
# Set up working directory and install dependencies
|
4 |
+
WORKDIR /code
|
5 |
|
6 |
+
COPY ./requirements.txt /code/requirements.txt
|
|
|
7 |
|
8 |
+
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
|
|
|
|
|
|
9 |
|
10 |
+
# Create a new user and set permissions
|
11 |
+
RUN useradd -m -u 1000 user
|
|
|
12 |
|
13 |
+
USER user
|
14 |
+
|
15 |
+
ENV HOME=/home/user \
|
16 |
+
PATH=/home/user/.local/bin:$PATH \
|
17 |
+
HF_HOME=/home/user/.cache/huggingface \
|
18 |
+
OPENAI_API_KEY=your_openai_api_key_here
|
19 |
+
|
20 |
+
WORKDIR $HOME/app
|
21 |
|
22 |
# Copy the rest of the application code into the container
|
23 |
+
COPY --chown=user . $HOME/app
|
24 |
+
|
25 |
+
# Ensure the cache directory has proper permissions
|
26 |
+
RUN mkdir -p $HF_HOME && chmod -R 777 $HF_HOME
|
27 |
|
28 |
# Expose the port the app runs on
|
29 |
EXPOSE 8000
|
30 |
|
31 |
+
# Run the application using uvicorn
|
32 |
+
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
|