Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +29 -8
Dockerfile
CHANGED
|
@@ -1,21 +1,42 @@
|
|
| 1 |
# Use an official Python runtime as a parent image
|
| 2 |
FROM python:3.8-slim
|
| 3 |
|
|
|
|
|
|
|
|
|
|
| 4 |
# Set the working directory in the container
|
| 5 |
WORKDIR /app
|
| 6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
# Copy the current directory contents into the container at /app
|
| 8 |
COPY . /app
|
| 9 |
|
| 10 |
-
#
|
| 11 |
-
RUN
|
| 12 |
|
| 13 |
-
#
|
| 14 |
-
|
| 15 |
|
| 16 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
EXPOSE 7860
|
| 18 |
|
| 19 |
-
#
|
| 20 |
-
|
| 21 |
-
|
|
|
|
|
|
|
|
|
| 1 |
# Use an official Python runtime as a parent image
|
| 2 |
FROM python:3.8-slim
|
| 3 |
|
| 4 |
+
# Create a non-root user
|
| 5 |
+
RUN useradd -m -u 1000 user
|
| 6 |
+
|
| 7 |
# Set the working directory in the container
|
| 8 |
WORKDIR /app
|
| 9 |
|
| 10 |
+
# Install system packages and Node.js as root first
|
| 11 |
+
RUN apt-get update && apt-get install -y \
|
| 12 |
+
curl \
|
| 13 |
+
&& curl -fsSL https://deb.nodesource.com/setup_18.x | bash - \
|
| 14 |
+
&& apt-get install -y nodejs \
|
| 15 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 16 |
+
|
| 17 |
+
# Install nport globally
|
| 18 |
+
RUN npm install -g nport
|
| 19 |
+
|
| 20 |
# Copy the current directory contents into the container at /app
|
| 21 |
COPY . /app
|
| 22 |
|
| 23 |
+
# Change ownership of the app directory to the user
|
| 24 |
+
RUN chown -R user:user /app
|
| 25 |
|
| 26 |
+
# Switch to the non-root user
|
| 27 |
+
USER user
|
| 28 |
|
| 29 |
+
# Set PATH to include user's local bin directory
|
| 30 |
+
ENV PATH="/home/user/.local/bin:${PATH}"
|
| 31 |
+
|
| 32 |
+
# Install Python packages as the user (using --user flag)
|
| 33 |
+
RUN pip install --user --no-cache-dir -r requirements.txt
|
| 34 |
+
|
| 35 |
+
# Expose port 7860 (Hugging Face Spaces default port)
|
| 36 |
EXPOSE 7860
|
| 37 |
|
| 38 |
+
# Define environment variable for Flask
|
| 39 |
+
ENV FLASK_APP=AgriGo/app.py
|
| 40 |
+
|
| 41 |
+
# Run the application on port 7860 for Hugging Face Spaces
|
| 42 |
+
CMD ["flask", "run", "--host=0.0.0.0", "--port=7860"]
|