Skip to content

Commit

Permalink
Use docker-compose for faster volume switching
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiasmullie committed Oct 13, 2017
1 parent abfc7c3 commit 7d79f11
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 23 deletions.
26 changes: 5 additions & 21 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,28 +1,12 @@
FROM php:cli

# install composer and a bunch of dependencies
RUN apt-get update && apt-get install -y git curl zip unzip zlib1g-dev
COPY . /var/www
WORKDIR /var/www

RUN apt-get update
RUN apt-get install -y zip unzip zlib1g-dev
RUN docker-php-ext-install zip
RUN docker-php-ext-install pcntl
RUN curl -sS https://getcomposer.org/installer | php
RUN mv composer.phar /usr/local/bin/composer

# pull in code
WORKDIR /var/www
COPY . .

# install dependencies
RUN rm -rf vendor
RUN composer install

# to support loading the directory as volume, we'll move vendor out of the way so it
# doesn't get overwritten by more recent code; we'll put it back before running anything
RUN mv vendor ../docker-vendor
RUN echo 'mv /var/www/vendor /var/current-vendor 2>/dev/null || : && \
mv /var/docker-vendor /var/www/vendor && \
/bin/sh -c "$@" || : && \
mv /var/www/vendor /var/docker-vendor && \
mv /var/current-vendor /var/www/vendor 2>/dev/null || :' > /etc/run.sh
ENTRYPOINT ["/bin/sh", "/etc/run.sh"]

CMD ["vendor/bin/phpunit"]
11 changes: 11 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: '3'
services:
php:
build:
context: .
dockerfile: Dockerfile
volumes:
- ./src:/var/www/src
- ./data:/var/www/data
- ./tests:/var/www/tests
- ./phpunit.xml.dist:/var/www/phpunit.xml.dist
11 changes: 9 additions & 2 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ docs:
image:
docker build -t matthiasmullie/minify .

up:
docker-compose up -d php

down:
docker-compose stop -t0 php

test:
[ ! -z `docker images -q matthiasmullie/minify` ] || make image
docker run --rm --name minify -v `pwd`:/var/www matthiasmullie/minify vendor/bin/phpunit
[ $(UP) -eq 1 ] && make up || true
$(eval cmd='docker-compose run php vendor/bin/phpunit')
eval $(cmd); status=$$?; [ $(DOWN) -eq 1 ] && make down; exit $$status

0 comments on commit 7d79f11

Please sign in to comment.