Use multi-stage build
This commit is contained in:
parent
92fc9622a3
commit
d5617fa646
29
Dockerfile
29
Dockerfile
@ -1,7 +1,6 @@
|
||||
FROM composer:1.5
|
||||
FROM php:7.1-fpm-alpine
|
||||
|
||||
WORKDIR /srv/app
|
||||
|
||||
RUN apk add --no-cache --virtual .persistent-deps \
|
||||
git \
|
||||
icu-libs \
|
||||
@ -22,17 +21,14 @@ RUN set -xe \
|
||||
&& docker-php-ext-enable --ini-name 05-opcache.ini opcache \
|
||||
&& apk del .build-deps
|
||||
|
||||
###> recipes ###
|
||||
###< recipes ###
|
||||
|
||||
COPY docker/app/php.ini /usr/local/etc/php/php.ini
|
||||
COPY --from=0 /usr/bin/composer /usr/bin/composer
|
||||
COPY docker/app/docker-entrypoint.sh /usr/local/bin/docker-app-entrypoint
|
||||
RUN chmod +x /usr/local/bin/docker-app-entrypoint
|
||||
|
||||
COPY docker/app/install-composer.sh /usr/local/bin/docker-app-install-composer
|
||||
RUN chmod +x /usr/local/bin/docker-app-install-composer
|
||||
|
||||
RUN set -xe \
|
||||
&& docker-app-install-composer \
|
||||
&& mv composer.phar /usr/local/bin/composer
|
||||
WORKDIR /srv/app
|
||||
ENTRYPOINT ["docker-app-entrypoint"]
|
||||
CMD ["php-fpm"]
|
||||
|
||||
# https://getcomposer.org/doc/03-cli.md#composer-allow-superuser
|
||||
ENV COMPOSER_ALLOW_SUPERUSER 1
|
||||
@ -40,9 +36,6 @@ ENV COMPOSER_ALLOW_SUPERUSER 1
|
||||
# Use prestissimo to speed up builds
|
||||
RUN composer global require "hirak/prestissimo:^0.3" --prefer-dist --no-progress --no-suggest --optimize-autoloader --classmap-authoritative --no-interaction
|
||||
|
||||
COPY docker/app/docker-entrypoint.sh /usr/local/bin/docker-app-entrypoint
|
||||
RUN chmod +x /usr/local/bin/docker-app-entrypoint
|
||||
|
||||
# Allow to use development versions of Symfony
|
||||
ARG STABILITY=stable
|
||||
ENV STABILITY ${STABILITY}
|
||||
@ -50,12 +43,12 @@ ENV STABILITY ${STABILITY}
|
||||
# Download the Symfony skeleton and leverage Docker cache layers
|
||||
RUN composer create-project "symfony/skeleton" . --stability=$STABILITY --prefer-dist --no-dev --no-progress --no-scripts --no-plugins --no-interaction
|
||||
|
||||
###> recipes ###
|
||||
###< recipes ###
|
||||
|
||||
COPY . .
|
||||
|
||||
RUN mkdir -p var/cache var/logs var/sessions \
|
||||
&& composer install --prefer-dist --no-dev --no-progress --no-suggest --classmap-authoritative --no-interaction \
|
||||
&& composer clear-cache \
|
||||
&& chown -R www-data var # Permissions hack because setfacl does not work on Mac and Windows
|
||||
|
||||
ENTRYPOINT ["docker-app-entrypoint"]
|
||||
CMD ["php-fpm"]
|
||||
&& chown -R www-data var
|
||||
|
@ -1,21 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Copyright (c) Nils Adermann, Jordi Boggiano
|
||||
# Origin: https://github.com/composer/composer/blob/master/doc/faqs/how-to-install-composer-programmatically.md
|
||||
# Licence: MIT
|
||||
|
||||
EXPECTED_SIGNATURE=$(php -r "echo trim(file_get_contents('https://composer.github.io/installer.sig'));")
|
||||
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
|
||||
ACTUAL_SIGNATURE=$(php -r "echo hash_file('SHA384', 'composer-setup.php');")
|
||||
|
||||
if [ "$EXPECTED_SIGNATURE" != "$ACTUAL_SIGNATURE" ]
|
||||
then
|
||||
>&2 echo 'ERROR: Invalid installer signature'
|
||||
rm composer-setup.php
|
||||
exit 1
|
||||
fi
|
||||
|
||||
php composer-setup.php --quiet
|
||||
RESULT=$?
|
||||
rm composer-setup.php
|
||||
exit $RESULT
|
Loading…
x
Reference in New Issue
Block a user