survey/Dockerfile
2025-11-24 15:09:22 +08:00

37 lines
953 B
Docker

# 使用Python基础镜像
FROM python:3.12-slim
# 设置工作目录
WORKDIR /app
# 设置时区为北京时间
ENV TZ=Asia/Shanghai
ENV DEBIAN_FRONTEND=noninteractive
# 使用阿里云镜像源更新系统包
RUN sed -i 's/deb.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list.d/debian.sources && \
apt-get update && \
apt-get install -y gcc sqlite3 && \
rm -rf /var/lib/apt/lists/*
# 复制requirements文件并安装Python依赖
COPY requirements.txt .
# 配置pip使用阿里云镜像源
RUN pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/ && \
pip config set global.trusted-host mirrors.aliyun.com && \
pip install --no-cache-dir -r requirements.txt
# 复制项目文件
COPY . .
# 暴露端口
EXPOSE 8000
# 设置环境变量
ENV PYTHONPATH=/app
ENV PYTHONUNBUFFERED=1
# 启动命令
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]