簡體   English   中英

從 repo 安裝 pip 時如何使 Dockerfile 緩存無效

[英]How to invalidate Dockerfile cache when pip installing from repo

I have a Dockerfile that needs to install the latest package code from a private git repo, however because the dockerfile/url/commit doesn't change (I just follow the latest in master), Docker will cache this request and won't pull最新的代碼。

我可以完全禁用構建緩存來解決問題 - 但這會導致構建緩慢。

我怎樣才能強制 docker 不為一個命令使用緩存?

FROM tiangolo/uvicorn-gunicorn-fastapi:python3.7

COPY ./requirements.txt /app

RUN pip install --upgrade pip
RUN pip install -r requirements.txt

# This needs to be separate to trigger to invalidate the build cache
RUN pip install -e git+https://TOKEN@github.com/user/private-package.git#egg=private_package

COPY ./main.py /app
COPY ./app /app/app

添加

ARG foo=bar

RUN pip install -e...在您的 docker 文件中。 然后在您的腳本中使用docker build....添加作為參數--build-arg foo="$(date -s)"

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM