AgriGo / Dockerfile
NitinBot001's picture
Update Dockerfile
3ffaf7a verified
# Use an official Python runtime as a parent image
FROM python:3.8-slim
# Create a non-root user
RUN useradd -m -u 1000 user
# Set the working directory in the container
WORKDIR /app
# Install system packages and Node.js as root first
RUN apt-get update && apt-get install -y \
curl \
&& curl -fsSL https://deb.nodesource.com/setup_18.x | bash - \
&& apt-get install -y nodejs \
&& rm -rf /var/lib/apt/lists/*
# Install nport globally
RUN npm install -g nport
# Copy the current directory contents into the container at /app
COPY . /app
# Change ownership of the app directory to the user
RUN chown -R user:user /app
# Switch to the non-root user
USER user
# Set PATH to include user's local bin directory
ENV PATH="/home/user/.local/bin:${PATH}"
# Install Python packages as the user (using --user flag)
RUN pip install --user --no-cache-dir -r requirements.txt
# Expose port 7860 (Hugging Face Spaces default port)
EXPOSE 7860
# Define environment variable for Flask
ENV FLASK_APP=AgriGo/app.py
# Run the application on port 7860 for Hugging Face Spaces
CMD ["flask", "run", "--host=0.0.0.0", "--port=7860"]