Skip to content

Commit 7d79f11

Browse files
Use docker-compose for faster volume switching
1 parent abfc7c3 commit 7d79f11

File tree

3 files changed

+25
-23
lines changed

3 files changed

+25
-23
lines changed

Dockerfile

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,12 @@
11
FROM php:cli
22

3-
# install composer and a bunch of dependencies
4-
RUN apt-get update && apt-get install -y git curl zip unzip zlib1g-dev
3+
COPY . /var/www
4+
WORKDIR /var/www
5+
6+
RUN apt-get update
7+
RUN apt-get install -y zip unzip zlib1g-dev
58
RUN docker-php-ext-install zip
69
RUN docker-php-ext-install pcntl
710
RUN curl -sS https://getcomposer.org/installer | php
811
RUN mv composer.phar /usr/local/bin/composer
9-
10-
# pull in code
11-
WORKDIR /var/www
12-
COPY . .
13-
14-
# install dependencies
15-
RUN rm -rf vendor
1612
RUN composer install
17-
18-
# to support loading the directory as volume, we'll move vendor out of the way so it
19-
# doesn't get overwritten by more recent code; we'll put it back before running anything
20-
RUN mv vendor ../docker-vendor
21-
RUN echo 'mv /var/www/vendor /var/current-vendor 2>/dev/null || : && \
22-
mv /var/docker-vendor /var/www/vendor && \
23-
/bin/sh -c "$@" || : && \
24-
mv /var/www/vendor /var/docker-vendor && \
25-
mv /var/current-vendor /var/www/vendor 2>/dev/null || :' > /etc/run.sh
26-
ENTRYPOINT ["/bin/sh", "/etc/run.sh"]
27-
28-
CMD ["vendor/bin/phpunit"]

docker-compose.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: '3'
2+
services:
3+
php:
4+
build:
5+
context: .
6+
dockerfile: Dockerfile
7+
volumes:
8+
- ./src:/var/www/src
9+
- ./data:/var/www/data
10+
- ./tests:/var/www/tests
11+
- ./phpunit.xml.dist:/var/www/phpunit.xml.dist

makefile

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ docs:
77
image:
88
docker build -t matthiasmullie/minify .
99

10+
up:
11+
docker-compose up -d php
12+
13+
down:
14+
docker-compose stop -t0 php
15+
1016
test:
11-
[ ! -z `docker images -q matthiasmullie/minify` ] || make image
12-
docker run --rm --name minify -v `pwd`:/var/www matthiasmullie/minify vendor/bin/phpunit
17+
[ $(UP) -eq 1 ] && make up || true
18+
$(eval cmd='docker-compose run php vendor/bin/phpunit')
19+
eval $(cmd); status=$$?; [ $(DOWN) -eq 1 ] && make down; exit $$status

0 commit comments

Comments
 (0)