从命名阶段复制失败,因为没有这样的文件或目录。

时间:2018-08-31 20:39:39

标签: docker dockerfile

想知道谁能提供帮助,因为我的所有搜索似乎都是徒劳的。

给出此docker文件:

# ------------ STAGE WKHTMLTOPDF

## madnight container needed due to qt, must have wkhtmltopdf with patched qt
FROM madnight/docker-alpine-wkhtmltopdf as madnight

# ------------ STAGE BASE LAYER
## Create a *base* image with all system dependencies
FROM php:7.1-fpm-alpine AS base

ENV REDIS_VERSION 4.0.2
ENV PHP_XDEBUG_DEFAULT_ENABLE ${PHP_XDEBUG_DEFAULT_ENABLE:-1}
ENV PHP_XDEBUG_REMOTE_ENABLE ${PHP_XDEBUG_REMOTE_ENABLE:-1}
ENV PHP_XDEBUG_REMOTE_HOST ${PHP_XDEBUG_REMOTE_HOST:-""}
ENV PHP_XDEBUG_REMOTE_PORT ${PHP_XDEBUG_REMOTE_PORT:-9000}
ENV PHP_XDEBUG_REMOTE_AUTO_START ${PHP_XDEBUG_REMOTE_AUTO_START:-1}
ENV PHP_XDEBUG_REMOTE_CONNECT_BACK ${PHP_XDEBUG_REMOTE_CONNECT_BACK:-1}
ENV PHP_XDEBUG_IDEKEY ${PHP_XDEBUG_IDEKEY:-"debugit"}
ENV PHP_XDEBUG_PROFILER_ENABLE ${PHP_XDEBUG_PROFILER_ENABLE:-0}
ENV PHP_XDEBUG_PROFILER_OUTPUT_DIR ${PHP_XDEBUG_PROFILER_OUTPUT_DIR:-"/tmp"}

## FPM Dependencies
RUN apk add --no-cache \
    --virtual .dd-build-deps \
        $PHPIZE_DEPS \
        libpng-dev \
        libjpeg-turbo-dev \
        postgresql-dev \
        libxml2-dev \
        icu-dev \
    && apk add --no-cache \
        libpng \
        libjpeg \
        libpq \
        libxml2 \
        icu \
    && docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql \
    && docker-php-ext-configure intl \
    && docker-php-ext-install \
        gd \
        pdo_mysql \
        pdo_pgsql \
        zip \
        opcache \
        bcmath \
        intl \
    && pecl install -o -f \
        redis \
        xdebug \
    &&  docker-php-ext-enable \
        redis \
        xdebug \
    && echo "xdebug.remote_enable=1" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
    && echo "xdebug.remote_handler=dbgp" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
    && echo "xdebug.remote_port=9000" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
    && echo "xdebug.remote_autostart=0" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
    && echo "xdebug.remote_connect_back=0" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
    && echo "xdebug.idekey=debugit" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
    && echo "xdebug.remote_host=$LOCAL_IP" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
    # WKHTMLTOPDF Dependencies
    && apk add --update --no-cache \
        libgcc \
        libstdc++ \
        libx11 glib \
        libxrender \
        libxext \
        libintl \
        libcrypto1.0 \
        libssl1.0 \
        ttf-dejavu \
        ttf-droid \
        ttf-freefont \
        ttf-liberation \
        ttf-ubuntu-font-family \
    # Clean up
    && apk del .dd-build-deps \
    && rm -rf /tmp/* \
    && rm -rf /var/cache/apk/*

COPY --from=madnight /bin/wkhtmltopdf /bin

# ------------ STAGE TAPIOCA PHP DEPENDENCIES
## Install Tapioca PHP dependencies
FROM base AS withPHPDependencies

ENV APP_DIR = /source-code
ENV COMPOSER_ALLOW_SUPERUSER 1

COPY ./ ${APP_DIR}
WORKDIR ${APP_DIR}

RUN apk add --update --no-cache \
        curl \
        git \
    && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer \
    && composer install  --optimize-autoloader

# ------------ STAGE TAPIOCA FRONT END DEPENDENCIES
## Install Tapioca Front-End dependencies
FROM node:6-alpine AS withFEDependendcies

WORKDIR /source-code

COPY --from=withPHPDependencies /source-code/ ./

# Since NPM loves to go crazy let's redirect everything to http for github
RUN git config --global url."https://github.com".insteadOf ssh://git@github.com && \
    npm install && \
    npm install -g phantomjs-prebuilt --unsafe-perm && \
    npm install -g https://github.com/hellofresh/lentil.git --unsafe-perm && \
    yarn --ignore-enginesyarn --ignore-engines && \
    ./lentil all angular,sass,libs,js

# Development Image
FROM base

ENV SOURCE_DIR = /source-code
ENV APP_DIR = /server/http

WORKDIR ${APP_DIR}

COPY --from=withFEDependendcies /source-code ./

VOLUME ${APP_DIR}

RUN cp ./docker/php-fpm/tapioca.ini /usr/local/etc/php/conf.d/ \
    && mkdir -p /var/log/ordering \
    && chmod -R 777 /var/log/ordering \
    && chown -R www-data:root /var/log/ordering \
    && chmod -R 777 ${APP_DIR}/app/cache

运行docker build -t dev-test:latest -f docker/dev/Dockerfile .失败

 ---> a15292733770
Step 23/31 : COPY --from=withPHPDependencies /source-code/ .
COPY failed: stat /var/lib/docker/overlay2/9eaa20ed309e8ffc27461fcf7809b9187a117de2dc318071713d696f27fdc078/merged/source-code: no such file or directory

将本地文件复制到withPHPDependencies,因为composer install步骤运行没有问题。我还注释掉了.dockerignore中的所有内容并运行了docker system prune -a

不确定我还能检查什么。

1 个答案:

答案 0 :(得分:2)

A!我瞎了。

Dockerfile不使用=来定义环境变量。一旦删除它们,一切便开始起作用。

感谢@BMitch提供更快的故障排除建议