simple-chatbot-openai/Dockerfile

33 lines
803 B
Docker
Raw Permalink Normal View History

2024-11-02 06:04:33 +00:00
# Use a slim base image to reduce potential vulnerabilities
2024-11-18 05:36:37 +00:00
FROM python:3.10-bookworm
2024-10-30 17:42:30 +07:00
2024-11-02 06:41:57 +00:00
# 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
2024-11-02 06:08:05 +00:00
2024-10-30 17:42:30 +07:00
# Set the working directory
WORKDIR /usr/src/app
2024-11-02 06:41:57 +00:00
# Copy the requirements file and install the dependencies as root
COPY requirements.txt .
2024-10-30 17:42:30 +07:00
2024-11-02 06:04:33 +00:00
RUN pip install --no-cache-dir uv==0.4.28 && \
pip install --no-cache-dir -r requirements.txt
2024-10-30 17:42:30 +07:00
2024-11-02 06:41:57 +00:00
# Copy the application code and set ownership to appuser
COPY . .
2024-11-02 06:04:33 +00:00
2024-11-02 06:41:57 +00:00
# Change ownership of the application directory to appuser
RUN chown -R appuser:appuser /usr/src/app
2024-11-02 06:29:38 +00:00
2024-11-02 06:04:33 +00:00
# Switch to the non-root user
USER appuser
# Expose the application port
2024-10-30 17:42:30 +07:00
EXPOSE 7860
2024-11-02 06:04:33 +00:00
# Set environment variables
2024-10-30 17:42:30 +07:00
ENV GRADIO_SERVER_NAME="0.0.0.0"
2024-11-05 10:10:36 +00:00
2024-11-02 06:04:33 +00:00
CMD ["python", "app.py"]