DaCrow13
Configura Prometheus per girare su Hugging Face Space
b4e6edc
FROM python:3.10-slim
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=off \
PIP_DISABLE_PIP_VERSION_CHECK=on \
PIP_DEFAULT_TIMEOUT=100
# Install system dependencies
RUN apt-get update && apt-get install -y \
git \
dos2unix \
nginx \
procps \
curl \
prometheus \
&& rm -rf /var/lib/apt/lists/*
# Create a non-root user
RUN useradd -m -u 1000 user
# Set working directory
WORKDIR /app
# Copy requirements first for caching
COPY requirements.txt .
# Remove -e . from requirements.txt to avoid installing the project before copying it
# and install dependencies
RUN sed -i '/-e \./d' requirements.txt && \
pip install --no-cache-dir -r requirements.txt
# Copy the rest of the application
COPY --chown=user:user . .
# Ensure the user has permissions on the app directory (needed for dvc init if .dvc is missing)
RUN chown -R user:user /app
# Fix line endings and permissions for the start script
RUN dos2unix scripts/start_space.sh && \
chmod +x scripts/start_space.sh
# Install the project itself
RUN pip install --no-cache-dir .
# Make start script executable
RUN chmod +x scripts/start_space.sh
# Switch to non-root user
USER user
# Expose the port
EXPOSE 7860
# Command to run the application
CMD ["./scripts/start_space.sh"]