Spaces:
Runtime error
Runtime error
Nishant Kumar commited on
Update Dockerfile
Browse files- Dockerfile +17 -21
Dockerfile
CHANGED
|
@@ -1,30 +1,26 @@
|
|
| 1 |
-
#
|
| 2 |
FROM python:3.9
|
| 3 |
|
| 4 |
-
#
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
# Create a non-root user and set permissions
|
| 8 |
-
RUN useradd -ms /bin/bash appuser
|
| 9 |
|
| 10 |
-
#
|
| 11 |
-
|
| 12 |
|
| 13 |
-
#
|
| 14 |
-
|
| 15 |
|
| 16 |
-
#
|
| 17 |
-
|
| 18 |
|
| 19 |
-
# Copy
|
| 20 |
-
COPY . .
|
| 21 |
-
RUN chown -R appuser:appuser /app
|
| 22 |
|
| 23 |
-
#
|
| 24 |
-
|
| 25 |
|
| 26 |
-
#
|
| 27 |
-
|
| 28 |
|
| 29 |
-
#
|
| 30 |
-
CMD ["gunicorn", "--bind", "0.0.0.0:7860", "
|
|
|
|
| 1 |
+
# Use Python 3.9 as the base image
|
| 2 |
FROM python:3.9
|
| 3 |
|
| 4 |
+
# Create a user named 'user' with UID 1000 and create its home directory
|
| 5 |
+
RUN useradd -m -u 1000 user
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
+
# Switch to the 'user' user for subsequent commands
|
| 8 |
+
USER user
|
| 9 |
|
| 10 |
+
# Add user's local bin directory to the PATH environment variable
|
| 11 |
+
ENV PATH="/home/user/.local/bin:$PATH"
|
| 12 |
|
| 13 |
+
# Set the working directory inside the container
|
| 14 |
+
WORKDIR /app
|
| 15 |
|
| 16 |
+
# Copy requirements.txt from the host to the container
|
| 17 |
+
COPY --chown=user ./requirements.txt requirements.txt
|
|
|
|
| 18 |
|
| 19 |
+
# Install Python dependencies listed in requirements.txt
|
| 20 |
+
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
| 21 |
|
| 22 |
+
# Copy the rest of the application code from the host to the container
|
| 23 |
+
COPY --chown=user . /app
|
| 24 |
|
| 25 |
+
# Specify the command to run the application with Gunicorn
|
| 26 |
+
CMD ["gunicorn", "--bind", "0.0.0.0:7860", "app:app"]
|