From 0f965c41a1f03e20a650682ea43cc03bb7b4c623 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Thu, 19 Oct 2017 14:03:21 +0200 Subject: [PATCH] Use composer create-project --- Dockerfile | 15 ++++++--------- docker/app/docker-entrypoint.sh | 9 ++++++--- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Dockerfile b/Dockerfile index fb7569d..c50f22b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,13 +1,13 @@ FROM php:7.1-fpm-alpine +WORKDIR /srv/app + RUN apk add --no-cache --virtual .persistent-deps \ git \ icu-libs \ - make \ zlib ENV APCU_VERSION 5.1.8 - RUN set -xe \ && apk add --no-cache --virtual .build-deps \ $PHPIZE_DEPS \ @@ -38,22 +38,19 @@ RUN set -xe \ 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 +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 # Download the Symfony skeleton and leverage Docker cache layers -ENV SKELETON_COMPOSER_JSON https://raw.githubusercontent.com/symfony/skeleton/v3.3.4/composer.json - -WORKDIR /srv/app -RUN php -r "copy('$SKELETON_COMPOSER_JSON', 'composer.json');" \ - && composer install --prefer-dist --no-dev --no-progress --no-suggest --no-autoloader --no-scripts --no-plugins --no-interaction +ENV STABILITY stable +RUN composer create-project "symfony/skeleton" . --stability=$STABILITY --prefer-dist --no-dev --no-progress --no-scripts --no-plugins --no-interaction COPY . . RUN mkdir -p var/cache var/logs var/sessions \ - && composer install --prefer-dist --no-dev --no-progress --no-suggest --optimize-autoloader --classmap-authoritative --no-interaction \ + && 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 diff --git a/docker/app/docker-entrypoint.sh b/docker/app/docker-entrypoint.sh index 23258c6..6aee256 100755 --- a/docker/app/docker-entrypoint.sh +++ b/docker/app/docker-entrypoint.sh @@ -7,10 +7,13 @@ if [ "${1#-}" != "$1" ]; then fi if [ "$1" = 'php-fpm' ] || [ "$1" = 'bin/console' ]; then - # The first time volumes are mounted, dependencies need to be reinstalled + # The first time volumes are mounted, the project needs to be recreated if [ ! -f composer.json ]; then - rm -Rf vendor/* - php -r "copy('$SKELETON_COMPOSER_JSON', 'composer.json');" + composer create-project "symfony/skeleton" tmp --stability=$STABILITY --prefer-dist --no-progress --no-interaction + cp -Rp tmp/. . + rm -Rf tmp/ + elif [ "$APP_ENV" != 'prod' ]; then + # Always try to reinstall deps when not in prod composer install --prefer-dist --no-progress --no-suggest --no-interaction fi