Files
kami_jd_ck/babel_channel/Dockerfile
2025-04-13 19:17:51 +08:00

52 lines
1.4 KiB
Docker

# 基于 Python 3.9-slim 镜像
FROM python:3.9-slim
# 修改apt-get源地址为阿里云镜像
RUN echo "" > /etc/apt/sources.list && \
echo "deb http://mirrors.aliyun.com/debian buster main" >> /etc/apt/sources.list && \
echo "deb http://mirrors.aliyun.com/debian-security buster/updates main" >> /etc/apt/sources.list && \
echo "deb http://mirrors.aliyun.com/debian buster-updates main" >> /etc/apt/sources.list
# 安装必要的工具和依赖
RUN apt-get update && apt-get install -y \
curl \
gnupg \
libgl1-mesa-glx \
libglib2.0-0 \
build-essential \
python3-dev \
libev-dev \
&& curl -fsSL https://deb.nodesource.com/setup_16.x | bash - \
&& apt-get install -y nodejs \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# 升级pip
RUN pip install --upgrade pip
# 设置工作目录
WORKDIR /app
# 先复制依赖文件
COPY requirements.txt .
# 安装Python依赖
RUN pip install -i https://pypi.tuna.tsinghua.edu.cn/simple gunicorn[gevent] gevent
RUN pip install --no-cache-dir -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple/
RUN pip install --no-cache-dir ddddocr -i https://pypi.tuna.tsinghua.edu.cn/simple/
# 创建日志目录
RUN mkdir -p /app/logs && chmod 777 /app/logs
# 复制应用代码
COPY . .
# 暴露容器端口
EXPOSE 5002
ENV FLASK_APP=app.py
ENV PYTHONUNBUFFERED=1
# 运行应用
CMD ["gunicorn", "-c", "gunicorn.conf.py", "app:app"]