Spaces:
Runtime error
Runtime error
adityasugandhi
commited on
Commit
·
1cc3de0
1
Parent(s):
de4ecd8
bug fix
Browse files- Dockerfile +20 -9
Dockerfile
CHANGED
|
@@ -1,19 +1,30 @@
|
|
| 1 |
FROM python:3.10
|
| 2 |
|
| 3 |
# Create a directory for the application and set permissions
|
| 4 |
-
|
| 5 |
-
|
|
|
|
| 6 |
|
| 7 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
WORKDIR /app
|
| 9 |
|
| 10 |
-
# Copy requirements file
|
| 11 |
COPY ./req.txt /app/req.txt
|
| 12 |
-
RUN pip install --upgrade pip && \
|
| 13 |
-
pip install --no-cache-dir -r req.txt
|
| 14 |
|
| 15 |
-
#
|
|
|
|
|
|
|
|
|
|
| 16 |
COPY . /app
|
| 17 |
|
| 18 |
-
# Run the application
|
| 19 |
-
CMD ["python", "app.py"]
|
|
|
|
| 1 |
FROM python:3.10
|
| 2 |
|
| 3 |
# Create a directory for the application and set permissions
|
| 4 |
+
# Set environment variables
|
| 5 |
+
ENV VIRTUAL_ENV=/opt/venv
|
| 6 |
+
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
|
| 7 |
|
| 8 |
+
# Install system dependencies
|
| 9 |
+
RUN apt-get update && \
|
| 10 |
+
apt-get install -y --no-install-recommends \
|
| 11 |
+
python3-venv \
|
| 12 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 13 |
+
|
| 14 |
+
# Set up virtual environment
|
| 15 |
+
RUN python3 -m venv $VIRTUAL_ENV
|
| 16 |
+
|
| 17 |
+
# Set working directory
|
| 18 |
WORKDIR /app
|
| 19 |
|
| 20 |
+
# Copy requirements file
|
| 21 |
COPY ./req.txt /app/req.txt
|
|
|
|
|
|
|
| 22 |
|
| 23 |
+
# Activate virtual environment and install project dependencies
|
| 24 |
+
RUN /bin/bash -c "source $VIRTUAL_ENV/bin/activate && pip install --upgrade pip && pip install --no-cache-dir -r req.txt"
|
| 25 |
+
|
| 26 |
+
# Copy application code
|
| 27 |
COPY . /app
|
| 28 |
|
| 29 |
+
# Run the application within the virtual environment
|
| 30 |
+
CMD ["/opt/venv/bin/python", "app.py"]
|