File size: 1,135 Bytes
b2ca329 9c1cc8f b2ca329 ed8aac4 b2ca329 a52d88d b2ca329 0c96375 95ccedb 0c96375 61c8727 a52d88d 61c8727 b2ca329 a52d88d b2ca329 a52d88d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
FROM python:3.10-slim
# Set working directory
WORKDIR /app
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PORT=7860
# Add build version to force rebuild when needed
LABEL build_version="1.0.1"
# Install only the required system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
gcc \
curl \
&& rm -rf /var/lib/apt/lists/*
# Copy requirements first to leverage Docker caching
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy mandatory application files
COPY app.py db_connector.py ./
# Create placeholder files for optional files
RUN touch .env.example
RUN touch .dockerignore
RUN touch .gitignore
RUN echo "# MongoDB Telegram Bot API" > README.md
# Create logs directory with proper permissions
RUN mkdir -p /app/logs && \
touch /app/app.log && \
chmod 666 /app/app.log
# Health check
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
CMD curl -f http://localhost:7860/health || exit 1
# Start the application with uvicorn
CMD uvicorn app:app --host 0.0.0.0 --port ${PORT} |