Skip to content

Commit 73d58e3

Browse files
committed
Improve volume handling
1 parent e291d45 commit 73d58e3

File tree

3 files changed

+8
-13
lines changed

3 files changed

+8
-13
lines changed

Dockerfile

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,7 @@ RUN rm -Rf docker/ Dockerfile docker-compose.yml
4848
ENV SKELETON_COMPOSER_JSON https://raw.githubusercontent.com/symfony/skeleton/v3.3.2/composer.json
4949
RUN [ -f composer.json ] || php -r "copy('$SKELETON_COMPOSER_JSON', 'composer.json');"
5050

51-
RUN mkdir -p \
52-
var/cache \
53-
var/logs \
54-
var/sessions \
51+
RUN mkdir -p var/cache var/logs var/sessions \
5552
&& composer install --prefer-dist --no-dev --no-progress --no-suggest --optimize-autoloader --classmap-authoritative --no-interaction \
5653
&& composer clear-cache \
5754
# Permissions hack because setfacl does not work on Mac and Windows

docker-compose.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ services:
55
build:
66
context: .
77
dockerfile: ./Dockerfile
8-
#depends_on:
9-
# - db
108
volumes:
119
# Comment out the next line in production
1210
- ./:/srv/app:rw
@@ -15,6 +13,7 @@ services:
1513
- /srv/app/var/cache/
1614
- /srv/app/var/logs/
1715
- /srv/app/var/sessions/
16+
- /srv/app/vendor/
1817

1918
nginx:
2019
build:

docker/app/docker-entrypoint.sh

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

99
if [ "$1" = 'php-fpm' ] || [ "$1" = 'bin/console' ]; then
10-
if [ "$APP_ENV" != 'prod' ]; then
11-
if [ ! -f composer.json ]; then
12-
php -r "copy('$SKELETON_COMPOSER_JSON', 'composer.json');"
13-
fi
14-
mkdir -p var
15-
composer install --prefer-dist --no-progress --no-suggest --no-interaction
16-
fi
10+
# The first time volumes are mounted, dependencies need to be reinstalled
11+
if [ ! -f composer.json ]; then
12+
rm -Rf vendor/*
13+
php -r "copy('$SKELETON_COMPOSER_JSON', 'composer.json');"
14+
composer install --prefer-dist --no-progress --no-suggest --no-interaction
15+
fi
1716

1817
# Permissions hack because setfacl does not work on Mac and Windows
1918
chown -R www-data var

0 commit comments

Comments
 (0)