cyberpunk-image-gen/Dockerfile

33 lines
829 B
Docker
Raw Permalink Normal View History

2024-12-11 15:16:03 +00:00
# Use a slim base image to reduce potential vulnerabilities
FROM python:3.10-slim-bookworm
# Create a non-root user and group with home directory set to /usr/src/app
RUN useradd --no-log-init -r -m -d /usr/src/app appuser
# Set the working directory
WORKDIR /usr/src/app
# Copy the requirements file and install the dependencies as root
COPY requirements.txt .
RUN pip install --no-cache-dir uv==0.4.28 && \
pip install --no-cache-dir -r requirements.txt
# Copy the application code and set ownership to appuser
COPY . .
# Change ownership of the application directory to appuser
RUN chown -R appuser:appuser /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"]