Skip to content

Commit

Permalink
Add volume for composer cache
Browse files Browse the repository at this point in the history
  • Loading branch information
jeckel committed Apr 24, 2018
1 parent 11c29fa commit bd3620a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
10 changes: 4 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
.PHONY: build composer composer-install composer-update

-include .env

__USER=$(shell id -u):$(shell id -g)
__COMPOSER_CMD=docker-compose run --rm --no-deps -u ${__USER} php composer

default: install up

build:
@docker build -t ${DOCKER_IMAGE} .

composer:
@${__COMPOSER_CMD} ${CMD}

composer-install:
composer-install: install
@${__COMPOSER_CMD} install

composer-update:
Expand All @@ -22,5 +17,8 @@ composer-update:
up:
@docker-compose up

down:
@docker-compose down -v --remove-orphans

install:
@./scripts/install.sh
5 changes: 4 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
version: "3"
volumes:
mysqldata:
composer-cache:
external: true

services:
mysql:
image: mysql:latest
Expand All @@ -23,7 +26,7 @@ services:
- mysql
volumes:
- ./:/project
user: 1000:1000
- composer-cache:/tmp/composer
environment:
- MYSQL_DATABASE=${MYSQL_DATABASE:-"my_database"}
- MYSQL_HOST=mysql
Expand Down
5 changes: 5 additions & 0 deletions scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ if [ ! -f $PROJECT_DIR/.env ]; then
cp $PROJECT_DIR/.env.dist $PROJECT_DIR/.env
fi

# Create volume for the composer's cache
if [ $(docker volume ls | grep -w composer-cache -c) -eq 0 ]; then
docker volume create composer-cache > /dev/null
fi

# Initialize composer
if [ ! -f $PROJECT_DIR/composer.json ]; then
${__COMPOSER_CMD} init
Expand Down

0 comments on commit bd3620a

Please sign in to comment.