simple-chatbot-crewai/Dockerfile

32 lines
757 B
Docker
Raw Permalink Normal View History

2024-12-06 13:06:17 +07:00
# Use a slim base image to reduce potential vulnerabilities
FROM python:3.10-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 -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"
CMD ["python", "app.py"]