Skip to content

Commit 0f965c4

Browse files
committed
Use composer create-project
1 parent 33daa22 commit 0f965c4

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

Dockerfile

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
FROM php:7.1-fpm-alpine
22

3+
WORKDIR /srv/app
4+
35
RUN apk add --no-cache --virtual .persistent-deps \
46
git \
57
icu-libs \
6-
make \
78
zlib
89

910
ENV APCU_VERSION 5.1.8
10-
1111
RUN set -xe \
1212
&& apk add --no-cache --virtual .build-deps \
1313
$PHPIZE_DEPS \
@@ -38,22 +38,19 @@ RUN set -xe \
3838
ENV COMPOSER_ALLOW_SUPERUSER 1
3939

4040
# Use prestissimo to speed up builds
41-
RUN composer global require "hirak/prestissimo:^0.3" --prefer-dist --no-progress --no-suggest --optimize-autoloader --classmap-authoritative
41+
RUN composer global require "hirak/prestissimo:^0.3" --prefer-dist --no-progress --no-suggest --optimize-autoloader --classmap-authoritative --no-interaction
4242

4343
COPY docker/app/docker-entrypoint.sh /usr/local/bin/docker-app-entrypoint
4444
RUN chmod +x /usr/local/bin/docker-app-entrypoint
4545

4646
# Download the Symfony skeleton and leverage Docker cache layers
47-
ENV SKELETON_COMPOSER_JSON https://raw.githubusercontent.com/symfony/skeleton/v3.3.4/composer.json
48-
49-
WORKDIR /srv/app
50-
RUN php -r "copy('$SKELETON_COMPOSER_JSON', 'composer.json');" \
51-
&& composer install --prefer-dist --no-dev --no-progress --no-suggest --no-autoloader --no-scripts --no-plugins --no-interaction
47+
ENV STABILITY stable
48+
RUN composer create-project "symfony/skeleton" . --stability=$STABILITY --prefer-dist --no-dev --no-progress --no-scripts --no-plugins --no-interaction
5249

5350
COPY . .
5451

5552
RUN mkdir -p var/cache var/logs var/sessions \
56-
&& composer install --prefer-dist --no-dev --no-progress --no-suggest --optimize-autoloader --classmap-authoritative --no-interaction \
53+
&& composer install --prefer-dist --no-dev --no-progress --no-suggest --classmap-authoritative --no-interaction \
5754
&& composer clear-cache \
5855
&& chown -R www-data var # Permissions hack because setfacl does not work on Mac and Windows
5956

docker/app/docker-entrypoint.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,13 @@ if [ "${1#-}" != "$1" ]; then
77
fi
88

99
if [ "$1" = 'php-fpm' ] || [ "$1" = 'bin/console' ]; then
10-
# The first time volumes are mounted, dependencies need to be reinstalled
10+
# The first time volumes are mounted, the project needs to be recreated
1111
if [ ! -f composer.json ]; then
12-
rm -Rf vendor/*
13-
php -r "copy('$SKELETON_COMPOSER_JSON', 'composer.json');"
12+
composer create-project "symfony/skeleton" tmp --stability=$STABILITY --prefer-dist --no-progress --no-interaction
13+
cp -Rp tmp/. .
14+
rm -Rf tmp/
15+
elif [ "$APP_ENV" != 'prod' ]; then
16+
# Always try to reinstall deps when not in prod
1417
composer install --prefer-dist --no-progress --no-suggest --no-interaction
1518
fi
1619

0 commit comments

Comments
 (0)