Files
railway_cloud/Dockerfile
2025-09-27 11:54:22 +08:00

37 lines
889 B
Docker

# 使用官方Python运行时作为基础镜像
FROM python:3.11-slim
# 设置工作目录
WORKDIR /app
# 设置环境变量
ENV PYTHONPATH=/app
ENV PYTHONUNBUFFERED=1
# 配置国内镜像源加速
RUN sed -i s@/deb.debian.org/@/mirrors.aliyun.com/@g /etc/apt/sources.list && \
apt-get update && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# 设置pip国内镜像源
RUN pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
# 复制依赖文件
COPY requirements.txt .
# 安装Python依赖
RUN pip install --no-cache-dir -r requirements.txt
# 复制应用代码
COPY . .
# 创建日志目录并设置权限
RUN mkdir -p /app/logs && chmod 755 /app/logs
# 暴露端口
EXPOSE 8000
# 启动命令,启用详细日志
CMD ["python", "-m", "uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000", "--access-log", "--log-level", "info"]