Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
1 contributor

Users who have contributed to this file

97 lines (77 sloc) 2.63 KB
ARG PHP_VERSION=7.2
FROM php:${PHP_VERSION}-fpm-alpine
ARG GID=1000
ARG UID=1000
ARG APCU_VERSION=5.1.12
ARG APP_ENV=prod
ARG WITH_XDEBUG=false
# Prevent Symfony Flex from generating a project ID at build time
ARG SYMFONY_SKIP_REGISTRATION=1
ENV APP_ENV=${APP_ENV}
ENV APP_PATH=/var/www/app
# alpine php already includes a www-data user, so its not needed to create
# we just create an unpriveledged user for our application. We set the 1000 id, so the permissions work
# when mounting the application volume. Need to investigate further to avoid this.
RUN addgroup app -g $GID && adduser -u $UID -D -G app app && addgroup app www-data
# Install Symfony requirements
RUN set -eux; \
apk add --no-cache --virtual .build-deps \
$PHPIZE_DEPS \
icu-dev \
libzip-dev \
zlib-dev \
; \
\
docker-php-ext-configure zip --with-libzip; \
docker-php-ext-install -j$(nproc) \
intl \
zip \
; \
pecl install \
apcu-${APCU_VERSION} \
; \
pecl clear-cache; \
docker-php-ext-enable \
apcu \
opcache \
; \
\
runDeps="$( \
scanelf --needed --nobanner --format '%n#p' --recursive /usr/local/lib/php/extensions \
| tr ',' '\n' \
| sort -u \
| awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \
)"; \
apk add --no-cache --virtual .api-phpexts-rundeps $runDeps; \
if [ $WITH_XDEBUG = "true" ] ; then \
pecl install xdebug; \
docker-php-ext-enable xdebug; \
echo "error_reporting = E_ALL" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini; \
echo "display_startup_errors = On" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini; \
echo "display_errors = On" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini; \
echo "xdebug.remote_enable=1" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini; \
fi ;
# Install Composer globally
ENV COMPOSER_ALLOW_SUPERUSER 1
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
COPY docker/php/php.ini /usr/local/etc/php/php.ini
WORKDIR ${APP_PATH}
COPY composer.json composer.lock ./
# prevent the reinstallation of vendors at every changes in the source code
RUN set -eux; \
composer install --prefer-dist --no-dev --no-autoloader --no-scripts --no-progress --no-suggest; \
composer clear-cache
COPY . ./
VOLUME ${APP_PATH}
RUN set -eux; \
mkdir -p var/cache var/log; \
composer dump-autoload --classmap-authoritative --no-dev; \
composer run-script --no-dev post-install-cmd; \
chown -R app:app var; \
chmod +x bin/console; sync
COPY docker/php/docker-entrypoint.sh /usr/local/bin/docker-entrypoint
RUN chmod +x /usr/local/bin/docker-entrypoint
USER app
EXPOSE 9000
ENTRYPOINT ["docker-entrypoint"]
CMD ["php-fpm", "-F"]
You can’t perform that action at this time.