Podman build 找不到指定文件夹中的 app.py
我正在第一次尝试在GCloud上部署我的模型,并且我使用的是podman。当我尝试用 podman build -t default-service-fastpai:latest .
来构建容器时,在第6步出错了。
STEP 6/8: COPY app /
Error: building at STEP "COPY app /": checking on sources under "Documents/Projects/Pred_default/app": copier: stat: "/app": no such file or directory
这个文件夹的结构如下:
└── Pred_default
└── app
└── Containerfile
└── app.py
└── app_test.py
└── lgb_credit_model.pkl
└── lgb_es_model.pkl
└── measure_response.py
└── requirements.txt
└── .gitignore
└── LICENSE.md
└── README.md
└── credit_predict.ipynb
└── requirements.txt
这是我的Containerfile。我不太明白哪里出了问题,app.py就在那儿,为什么podman看不到它呢?
FROM python:3.10-slim
RUN mkdir /app
# Set the working directory
WORKDIR /app
# Copy the requirements file into the container
COPY requirements.txt requirements.txt
# Install the required packages
RUN pip install --upgrade pip
RUN pip install -r requirements.txt
# Copy the application code into the container
COPY app /
# COPY ["lgb_credit_model.pkl", "lgb_es_model.pkl" "app.py", "./"]
# Expose the app port
EXPOSE 80
# Run command
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "80"]
1 个回答
0
根据你分享的错误信息和你的Containerfile,问题出在你的COPY
命令找不到指定的app
目录。它试图把app
目录复制到容器的根目录(/
),但看起来你其实是想把它复制到你在容器内创建的/app
目录里。
你需要把Containerfile中的COPY
命令从:
COPY app /
改成:
COPY app/ /app/
这样就能正确地把你本地的app
目录内容复制到容器内的/app
目录了。
另外,确保你是在Pred_default
目录下运行podman build
命令,因为app
目录就在这个位置。