From bd3620ad6104a0bcf2d1d42aa31b8fde08f08645 Mon Sep 17 00:00:00 2001 From: Jeckel Date: Tue, 24 Apr 2018 12:04:13 +0200 Subject: [PATCH] Add volume for composer cache --- Makefile | 10 ++++------ docker-compose.yml | 5 ++++- scripts/install.sh | 5 +++++ 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 4caed73..fc91f53 100644 --- a/Makefile +++ b/Makefile @@ -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: @@ -22,5 +17,8 @@ composer-update: up: @docker-compose up +down: + @docker-compose down -v --remove-orphans + install: @./scripts/install.sh diff --git a/docker-compose.yml b/docker-compose.yml index 50a6f43..7743c67 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,6 +1,9 @@ version: "3" volumes: mysqldata: + composer-cache: + external: true + services: mysql: image: mysql:latest @@ -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 diff --git a/scripts/install.sh b/scripts/install.sh index 1aa1fed..5f1ee81 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -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