FROM python:3.9-slim WORKDIR /app COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt COPY . . # 设置环境变量 ENV PORT=5000 ENV HOST=0.0.0.0 ENV DEBUG=False # Redis连接URL可以在运行容器时通过环境变量传入 # ENV REDIS_URL=redis://redis:6379/0 # ENV API_KEY=your_api_key EXPOSE 5000 # 使用Gunicorn作为生产级WSGI服务器 CMD gunicorn --workers=4 --bind ${HOST}:${PORT} mail_api:app