tima_chatbot / Dockerfile
Skier8402's picture
Upload Dockerfile
39d18b2 verified
# Use Python 3.11 slim image as base
FROM python:3.13-slim
# Set working directory
WORKDIR /app
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1
# Install system dependencies including curl for health check
RUN apt-get update && apt-get install -y \
--no-install-recommends \
gcc \
curl \
&& rm -rf /var/lib/apt/lists/*
# Copy requirements first for better Docker layer caching
COPY requirements.txt .
# Install Python dependencies
RUN pip --no-cache-dir install --upgrade pip && \
pip --no-cache-dir install -r requirements.txt
# Copy application files
COPY app2.py .
COPY prompts.py .
# Create log directory and set proper permissions
RUN mkdir -p /app/logs && \
chmod 755 /app/logs
# Create a non-root user for security
RUN useradd --create-home --shell /bin/bash app && \
chown -R app:app /app
USER app
# Expose the port the app runs on
EXPOSE 7860
# Health check
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
CMD curl -f http://localhost:7860/ || exit 1
# Run the application
CMD ["python", "app2.py"]
# Usage Instructions:
# 1. Build: docker build -t tima-chatbot .
# 2. Run: docker run -d -p 7860:7860 -e TIMA_API_KEY="your-api-key-here" --name tima-app tima-chatbot
# 3. Access: http://localhost:7860
# 4. Stop: docker stop tima-app
# 5. Remove: docker rm tima-app