簡體   English   中英

谷歌雲或 Docker 無法識別文件夾

[英]Google cloud or Docker not recognizing folder

我有一個具有以下結構的項目:

vineetkalghatgi@vinux:~/personal-projects/bertQA_server$ ls
bert-server-env  cloudbuild.yaml  Dockerfile  main.py  mymodel  Procfile  __pycache__  README.md  requirements.txt  target

我的.dockerignore:

Dockerfile
README.md
*.pyc
*.pyo
*.pyd
__pycache__
.pytest_cache
bert-server-env

這是我的 Dockerfile

FROM tensorflow/tensorflow

# Allow statements and log messages to immediately appear in the Knative logs
ENV PYTHONUNBUFFERED True

# Copy local code to the container image.
ENV APP_HOME /app
WORKDIR $APP_HOME
ADD mymodel .
COPY . .

# Install dependencies
RUN apt-get update \
    && apt-get upgrade -y \
    && apt-get autoremove -y \
    && apt-get clean

# Install production dependencies.
RUN pip3 install -r requirements.txt

# Run the web service on container startup. Here we use the gunicorn
# webserver, with one worker process and 8 threads.
# For environments with multiple CPU cores, increase the number of workers
# to be equal to the cores available.
# Timeout is set to 0 to disable the timeouts of the workers to allow Cloud Run to handle instance scaling.
CMD exec gunicorn --bind :$PORT --workers 1 --threads 8 --timeout 0 main:app

我以前只有COPY . . COPY . . 沒有ADD並注意到“mymodel”文件夾沒有被復制。 如果我運行gcloud build submit . --tag <my-gcr.io-container gcloud build submit . --tag <my-gcr.io-container我收到以下錯誤:

Step 5/9 : ADD mymodel .
ADD failed: file not found in build context or excluded by .dockerignore: stat mymodel: file does not exist

而且我可以使用docker build在本地構建映像,沒有任何問題。

使用gcloud build submit ,如果工作目錄中有Dockerfile ,則不需要cloudbuild.yaml 因為你有一個cloudbuild.yaml ,我懷疑它是優先的。

Q1: cloudbuild.yaml的內容是cloudbuild.yaml

Cloud SDK 使用.gcloudignore文件來忽略上傳到 Cloud Build 的文件。

Q2:你有.gcloudignore文件還是.gitignore文件?

ls -1a (其中 1==one)或 l=lowercase L 也將顯示隱藏文件會很有用。

暫無
暫無

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

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