All checks were successful
society-ai-hub-container-cache Actions Demo / build (push) Successful in 2m19s
34 lines
892 B
Docker
34 lines
892 B
Docker
# Use a slim base image to reduce potential vulnerabilities
|
|
FROM python:3.10-slim-bookworm
|
|
|
|
# Create a non-root user and group
|
|
RUN groupadd -r appuser && useradd --no-log-init -r -g appuser appuser
|
|
|
|
# Set the working directory
|
|
WORKDIR /usr/src/app
|
|
|
|
# Copy the requirements file and install the dependencies
|
|
COPY --chown=appuser:appuser requirements.txt .
|
|
|
|
# Install uv and the dependencies without caching to reduce image size
|
|
RUN pip install --no-cache-dir uv==0.4.28 && \
|
|
pip install --no-cache-dir -r requirements.txt
|
|
|
|
# Copy the application code with appropriate ownership
|
|
COPY --chown=appuser:appuser . .
|
|
|
|
# Change permissions of the application directory
|
|
RUN chmod -R 700 /usr/src/app
|
|
|
|
# Switch to the non-root user
|
|
USER appuser
|
|
|
|
# Expose the application port
|
|
EXPOSE 7860
|
|
|
|
# Set environment variables
|
|
ENV GRADIO_SERVER_NAME="0.0.0.0"
|
|
|
|
# Run the application
|
|
CMD ["python", "app.py"]
|