简体   繁体   English

谷歌云或 Docker 无法识别文件夹

[英]Google cloud or Docker not recognizing folder

I have a project with the following strucure :我有一个具有以下结构的项目:

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

My .dockerignore:我的.dockerignore:

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

This is my Dockerfile这是我的 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

I previously just had COPY . .我以前只有COPY . . COPY . . without the ADD and noticed that the 'mymodel' folder was not getting copied.没有ADD并注意到“mymodel”文件夹没有被复制。 If i run gcloud build submit . --tag <my-gcr.io-container如果我运行gcloud build submit . --tag <my-gcr.io-container gcloud build submit . --tag <my-gcr.io-container I get the following error: 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

And I am able to build the image locally with docker build with no issues.而且我可以使用docker build在本地构建映像,没有任何问题。

With gcloud build submit , if you have a Dockerfile in the working directory, you don't need a cloudbuild.yaml .使用gcloud build submit ,如果工作目录中有Dockerfile ,则不需要cloudbuild.yaml Because you have a cloudbuild.yaml , I suspect that it is taking priority.因为你有一个cloudbuild.yaml ,我怀疑它是优先的。

Q1: What is the content of cloudbuild.yaml ? Q1: cloudbuild.yaml的内容是cloudbuild.yaml

Cloud SDK uses a .gcloudignore file to ignore files that are eg uploaded to Cloud Build. Cloud SDK 使用.gcloudignore文件来忽略上传到 Cloud Build 的文件。

Q2: Do you have a .gcloudignore file or .gitignore file? Q2:你有.gcloudignore文件还是.gitignore文件?

It'd be useful to ls -1a (where 1==one) or l=lowercase L will show hidden files too. ls -1a (其中 1==one)或 l=lowercase L 也将显示隐藏文件会很有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM