优化安装了psycopg2的python镜像大小

下面这个Dockerfile是程序原本的Dockerfile 1 2 3 4 5 6 7 8 9 10 11 FROM python:3.10-slim-buster WORKDIR /app COPY requirements.txt requirements.txt RUN pip3 install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple --no-cache-dir \ && pip3 install torch==2.3.1+cpu --no-cache-dir -f https://download.pytorch.org/whl/torch_stable.html COPY . . CMD ["python3", "main.py", "web"] 现在要在镜像中安装psycopg2来使用postgresql ...

2025-06-17 · 2 分钟 · HZhang