Writing_Tutor / Dockerfile
NavyDevilDoc's picture
Update Dockerfile
ff85e7e verified
# Use an official lightweight Python image.
FROM python:3.11-slim
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
# Create a non-root user (Recommended for HF Spaces security permissions)
RUN useradd -m -u 1000 user
USER user
ENV PATH="/home/user/.local/bin:$PATH"
# Set the working directory in the container
WORKDIR /app
# Copy the requirements file first to leverage Docker cache
# Note the --chown flag to ensure the non-root user owns the files
COPY --chown=user ./requirements.txt requirements.txt
# Install dependencies
RUN pip install --no-cache-dir --upgrade -r requirements.txt
# Copy the rest of the application code
COPY --chown=user . /app
# Expose the port strictly required by Hugging Face Spaces
EXPOSE 7860
# Healthcheck updated to check the correct port
HEALTHCHECK CMD curl --fail http://localhost:7860/_stcore/health || exit 1
# Command to run the application
# Note the addition of --server.port=7860
CMD ["streamlit", "run", "app.py", "--server.address=0.0.0.0", "--server.port=7860"]