From 3bae622d275c7cb21e64e1ccc55d8771dea32c97 Mon Sep 17 00:00:00 2001 From: Rob Bast Date: Tue, 4 Sep 2018 09:14:03 +0200 Subject: [PATCH] tweak docker build --- .dockerignore | 17 +++++++++-------- Dockerfile | 44 +++++++++++++++++--------------------------- php-cli.ini | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 64 insertions(+), 35 deletions(-) create mode 100644 php-cli.ini diff --git a/.dockerignore b/.dockerignore index 3e435513..1257be19 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,9 +1,10 @@ * -!bin -!docs -!res -!src -!views -!composer.json -!composer.lock -!LICENSE +!/bin/ +!/docs/ +!/res/ +!/src/ +!/views/ +!/composer.json +!/composer.lock +!/LICENSE +!/php-cli.ini diff --git a/Dockerfile b/Dockerfile index c17de119..4381c55f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,46 +1,36 @@ -FROM php:7-alpine +FROM php:7-cli-alpine MAINTAINER https://github.com/composer/satis -RUN apk --no-cache add curl git subversion mercurial openssh openssl tini zlib-dev - -RUN docker-php-ext-install zip \ - && echo "memory_limit=-1" > "$PHP_INI_DIR/conf.d/memory-limit.ini" \ - && echo "date.timezone=${PHP_TIMEZONE:-UTC}" > "$PHP_INI_DIR/conf.d/date_timezone.ini" +RUN apk --no-cache add curl git subversion mercurial openssh openssl tini \ + && apk add --update --no-cache --virtual .build-deps zlib-dev \ + && docker-php-ext-install -j$(getconf _NPROCESSORS_ONLN) zip \ + && 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 --virtual .phpext-rundeps $runDeps \ + && apk del .build-deps ENV COMPOSER_HOME /composer ENV PATH "/composer/vendor/bin:$PATH" ENV COMPOSER_ALLOW_SUPERUSER 1 -RUN mkdir /build \ - && mkdir /composer \ - && chmod -R 777 /composer \ - && curl -sfLo /tmp/composer-setup.php https://getcomposer.org/installer \ - && curl -sfLo /tmp/composer-setup.sig https://composer.github.io/installer.sig \ - && php -r " \ - \$hash = hash('SHA384', file_get_contents('/tmp/composer-setup.php')); \ - \$signature = trim(file_get_contents('/tmp/composer-setup.sig')); \ - if (!hash_equals(\$signature, \$hash)) { \ - unlink('/tmp/composer-setup.php'); \ - echo 'Integrity check failed, installer is either corrupt or worse.' . PHP_EOL; \ - exit(1); \ - }" \ - && php /tmp/composer-setup.php --no-ansi --install-dir=/usr/bin --filename=composer \ - && composer --no-interaction --no-ansi --version \ - && rm /tmp/composer-setup.php +COPY php-cli.ini /usr/local/etc/php/ +COPY --from=composer:latest /usr/bin/composer /usr/bin/composer WORKDIR /satis COPY ["composer.json", "composer.lock", "/satis/"] - -RUN composer install --no-interaction --no-ansi --no-autoloader --no-scripts --no-plugins --no-dev - COPY bin /satis/bin/ COPY res /satis/res/ -COPY views /satis/views/ COPY src /satis/src/ +COPY views /satis/views/ -RUN composer dump-autoload --no-interaction --no-ansi --optimize --no-dev +RUN composer install --no-interaction --no-ansi --no-scripts --no-plugins --no-dev --optimize-autoloader \ + && rm -rf /composer/cache/files/* /composer/cache/repo/* ENTRYPOINT ["/sbin/tini", "-g", "--", "/satis/bin/docker-entrypoint.sh"] diff --git a/php-cli.ini b/php-cli.ini new file mode 100644 index 00000000..015b71fb --- /dev/null +++ b/php-cli.ini @@ -0,0 +1,38 @@ +; Maximum amount of memory a script may consume +memory_limit = -1 + +; This directive informs PHP of which errors, warnings and notices you would like +; it to take action for. The recommended way of setting values for this +; directive is through the use of the error level constants and bitwise +; operators. +error_reporting = -1 + +; This directive controls whether or not and where PHP will output errors, +; notices and warnings too. Error output is very useful during development, but +; it could be very dangerous in production environments. Depending on the code +; which is triggering the error, sensitive information could potentially leak +; out of your application such as database usernames and passwords or worse. +; For production environments, we recommend logging errors rather than +; sending them to STDOUT. +display_errors = on + +; The display of errors which occur during PHP's startup sequence are handled +; separately from display_errors. PHP's default behavior is to suppress those +; errors from clients. Turning the display of startup errors on can be useful in +; debugging configuration problems. We strongly recommend you +; set this to 'off' for production servers. +display_startup_errors = on + +; Besides displaying errors, PHP can also log errors to locations such as a +; server-specific log, STDERR, or a location specified by the error_log +; directive found below. While errors should not be displayed on productions +; servers they should still be monitored and logging is a great way to do that. +log_errors = on + +; Log errors to specified file. PHP's default behavior is to leave this value +; empty. +error_log = /tmp/php.log + +; Set maximum length of log_errors. In error_log information about the source is +; added. The default is 1024 and 0 allows to not apply any maximum length at all. +log_errors_max_len = 0