Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +12 -6
Dockerfile
CHANGED
@@ -1,21 +1,27 @@
|
|
1 |
# Use a Python 3.10 Slim image as the base
|
2 |
FROM python:3.10-slim
|
3 |
|
4 |
-
# Set the working directory
|
5 |
WORKDIR /code
|
6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
# Copy the requirements file to the container
|
8 |
COPY ./requirements.txt /code/requirements.txt
|
9 |
|
10 |
-
#
|
11 |
-
RUN chown -R root:root /code
|
12 |
-
|
13 |
-
# Upgrade pip to the latest version and install the dependencies
|
14 |
RUN pip install --no-cache-dir --upgrade pip && \
|
15 |
pip install --no-cache-dir -r /code/requirements.txt
|
16 |
|
17 |
# Copy the rest of the project files into the container
|
18 |
COPY . .
|
19 |
|
20 |
-
# Set the default command to run your application
|
21 |
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
1 |
# Use a Python 3.10 Slim image as the base
|
2 |
FROM python:3.10-slim
|
3 |
|
4 |
+
# Set the working directory
|
5 |
WORKDIR /code
|
6 |
|
7 |
+
# Install virtualenv to create a virtual environment
|
8 |
+
RUN pip install --no-cache-dir virtualenv
|
9 |
+
|
10 |
+
# Create and activate the virtual environment
|
11 |
+
RUN python -m venv /code/venv
|
12 |
+
|
13 |
+
# Ensure the virtual environment is used for subsequent pip installations
|
14 |
+
ENV PATH="/code/venv/bin:$PATH"
|
15 |
+
|
16 |
# Copy the requirements file to the container
|
17 |
COPY ./requirements.txt /code/requirements.txt
|
18 |
|
19 |
+
# Install dependencies inside the virtual environment
|
|
|
|
|
|
|
20 |
RUN pip install --no-cache-dir --upgrade pip && \
|
21 |
pip install --no-cache-dir -r /code/requirements.txt
|
22 |
|
23 |
# Copy the rest of the project files into the container
|
24 |
COPY . .
|
25 |
|
26 |
+
# Set the default command to run your application (inside the virtual environment)
|
27 |
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|