Ошибка сборки в Google Cloud Builder. На этой строке `COPY. / Код / ` - PullRequest
0 голосов
/ 08 марта 2020

Этот проект использует Google Cloud Builder с 2 месяца go. Однако со вчерашнего дня сборка не удалась.

Точка ошибки COPY . /code/. Он получает эту ошибку.

COPY . /code/                                
error building image: error building stage: failed to execute command: lstat /Users: no such file or directory
ERROR
ERROR: build step 0 "gcr.io/kaniko-project/executor:latest" failed: step exited with non-zero status: 1
--------------------------------------------------------------------------------------------------------------------

ERROR: (gcloud.builds.submit) build ab3ff4e4-85fb-4000-870e-86f34c0bf8ac completed with status "FAILURE"

Файл Docker ниже

# Copyright 2013 Thatcher Peskens
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

FROM python:3

MAINTAINER Dockerfiles


# timezone setting
RUN DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y tzdata
# timezone setting
ENV TZ=Asia/Tokyo 


# Install required packages and remove the apt packages cache when done.

RUN apt-get update && \
    apt-get upgrade -y && \
    apt-get install -y \
    vim \
    python3 \
    python3-dev \
    python3-setuptools \
    python3-pip \
    libssl-dev \
    nginx \
    supervisor \
    cron \
    && \
   rm -rf /var/lib/apt/lists/*

RUN pip3 install --upgrade pip
RUN pip3 install -U pip setuptools


# encode setting
# set the locale
RUN apt-get clean && apt-get update && apt-get install -y locales
# encode and locale settings
ENV LANG ja_JP.utf8
ENV TZ=Asia/Tokyo

#don't show error message
ENV DEBCONF_NOWARNINGS yes

# install uwsgi now because it takes a little while
RUN pip3 install uwsgi

RUN PYTHONPATH=/usr/bin/python3

RUN echo "daemon off;" >> /etc/nginx/nginx.conf
COPY nginx-app.conf /etc/nginx/sites-available/default
COPY supervisor-app.conf /etc/supervisor/conf.d/
COPY cron/crontab /var/spool/cron/crontabs/root

# COPY requirements.txt and RUN pip install BEFORE adding the rest of your code, this will cause Docker's caching mechanism
# to prevent re-installing (all your) dependencies when you made a change a line or two in your app.

COPY app/requirements.txt /code/app/
RUN pip3 install -r /code/app/requirements.txt

# add (the rest of) our code
COPY . /code/

RUN chmod 0744 /code/cron/*
RUN crontab /code/cron/crontab

ENV PYTHONPATH /usr/bin/python3

# install django, normally you would remove this step because your project would already
# be installed in the code/app/ directory
#RUN django-admin.py startproject website /code/app/

# this line do collectstatic and migrate
#RUN cd /code/app && /usr/bin/python3 manage.py collectstatic --no-input;/usr/bin/python3 manage.py migrate;

EXPOSE 8080
CMD ["supervisord", "-n"]

Я строю по этой команде.

cd ~/path/to/project/
gcloud builds submit --tag gcr.io/my/project . 

Что я сделал

  • COPY . /code/ перейти к после FROM python:3
  • COPY . /code/ изменить на COPY . /code/
  • COPY . /code/ изменить на COPY ./ /code/
  • COPY . /code/ изменить на COPY ./* /code/
  • COPY . /code/ изменить на ADD . /code/

Все получил ту же ошибку на линии.

Когда я строю на локальном docker build -t my_project ., оно было завершено.

Среда

  • gloculd core: [2020.02.28] beta: [2019.05.17]
  • macOS 10.14.6

Если у вас есть решение, пожалуйста, помогите мне!

1 Ответ

1 голос
/ 09 марта 2020

Я решил эту проблему. Решением является копирование всех файлов и каталогов. Это мои файлы.

enter image description here

Я изменил COPY . /code/, чтобы выбрать каждый файл.

COPY app/manage.py /code/app/
COPY app/affiliator/ /code/app/affiliator/
COPY app/post/ /code/app/post/
COPY app/assets/ /code/app/assets/
COPY app/media/ /code/app/media/
COPY app/website/ /code/app/website/
COPY app/owner/ /code/app/owner/
COPY app/base/ /code/app/base/
COPY cron/ /code/cron/
COPY uwsgi.ini /code/
COPY uwsgi_params /code/

Однако это справляющееся лечение, и первопричина неизвестна.

...