# Stage 1: Builder FROM python:3-alpine AS builder WORKDIR /app # Create virtual environment and set environment variables RUN python3 -m venv venv ENV VIRTUAL_ENV=/app/venv ENV PATH="$VIRTUAL_ENV/bin:$PATH" # Copy all project files to the container COPY . . # Install dependencies from requirements.txt RUN pip install -r requirements.txt # Stage 2: Runner FROM python:3-alpine AS runner WORKDIR /app # Copy virtual environment from the builder stage COPY --from=builder /app/venv venv # Copy all files again (including the ones that may have been modified in the builder stage) COPY . . # Set environment variables for the virtual environment ENV VIRTUAL_ENV=/app/venv ENV PATH="$VIRTUAL_ENV/bin:$PATH" # Ensure that all files and folders have 777 permissions (read, write, and execute) RUN chmod -R 777 /app # Set environment variable to specify session directory ENV TELETHON_SESSION_DIR="/app/session" # Expose the port where the Flask app will be running EXPOSE 7860 # Run the script CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]