File size: 988 Bytes
4ff0ec9 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | FROM python:3.11-slim
# Non-interactive
ENV PYTHONUNBUFFERED=1 DEBIAN_FRONTEND=noninteractive
WORKDIR /app
# Install minimal system dependencies
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
git \
curl \
build-essential \
&& rm -rf /var/lib/apt/lists/*
# Copy and install Python deps first for better caching
COPY requirements.txt /app/requirements.txt
RUN pip install --no-cache-dir -r /app/requirements.txt
# Copy the rest of the project
COPY . /app
# Create a non-root user and use it
RUN useradd -m appuser || true
RUN chown -R appuser:appuser /app
USER appuser
# Expose the Gradio default port
EXPOSE 7860
ENV PORT=7860
# Launch the Gradio `demo` object defined in app.py and bind to 0.0.0.0
# We import the module and call demo.launch(...) so the container starts the web UI
CMD ["bash", "-lc", "python -c \"import app; app.demo.launch(server_name='0.0.0.0', server_port=int(__import__('os').environ.get('PORT',7860)))\""]
|