我有Dockerfile:
FROM php:7.2.10-fpm-alpine as build
RUN apk upgrade --update && apk --no-cache add \
gcc g++ make git autoconf tzdata openntpd libcurl curl-dev coreutils \
freetype-dev libxpm-dev libjpeg-turbo-dev libvpx-dev \
libpng-dev ca-certificates libressl libressl-dev libxml2-dev postgresql-dev icu-dev rabbitmq-c-dev
RUN docker-php-ext-configure intl \
&& docker-php-ext-configure opcache \
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ \
--with-jpeg-dir=/usr/include/ --with-png-dir=/usr/include/ \
--with-xpm-dir=/usr/include/
RUN docker-php-ext-install -j$(nproc) \
gd \
pdo_pgsql \
xmlrpc \
zip \
bcmath \
intl \
opcache \
pcntl
# Install dependencies
RUN docker-php-source extract \
&& pecl install redis-4.1.1 apcu-5.1.12 amqp-1.9.3
RUN docker-php-ext-enable redis apcu amqp \
&& docker-php-source delete
# Add timezone
RUN rm /etc/localtime && \
ln -s /usr/share/zoneinfo/UTC /etc/localtime && \
"date"
# Install composer
RUN curl -sS https://getcomposer.org/installer | \
php -- --install-dir=/usr/local/bin --filename=composer
# Cleanup
RUN rm -rf /var/cache/apk/* \
&& find / -type f -iname \*.apk-new -delete \
&& rm -rf /var/cache/apk/*
ADD php.ini /usr/local/etc/php/php.ini
ADD opcache.ini /usr/local/etc/php/conf.d/opcache.ini
ADD www.conf /usr/local/etc/php/php-fpm.d/www.conf
ADD php-fpm.conf /usr/local/etc/php/php-fpm.d/php-fpm
EXPOSE 9000
CMD ["php-fpm"]
#Dev
FROM build as dev
ADD xdebug.ini /usr/local/etc/php/conf.d/xdebug.ini
RUN docker-php-source extract && pecl install xdebug-2.6.1
RUN docker-php-ext-enable xdebug && docker-php-source delete
#Production
FROM build as prod
ARG REPOSITORY_URL
ARG CHECKOUT_POSITION
RUN mkdir /var/www/project
RUN git clone $REPOSITORY_URL /var/www/project \
&& cd /var/www/project \
&& git reset --hard $CHECKOUT_POSITION \
&& env APP_ENV=prod composer install --no-dev --optimize-autoloader \
&& chown -R www-data:www-data /var/www/project
WORKDIR /var/www/project
USER www-data
当我从开发阶段开始使用docker build --target prod
依赖项进行生产时(xdebug等)。
如果prod阶段移至dev之上,则prod的dev阶段复制依赖项。
可能是什么?
Docker版本18.06.1-ce,内部版本e68fc7a
UPD:Dockerfile已更新
代码太多,无法保存。代码太多,无法保存。代码太多,无法保存。
谢谢。