Skip to content

Commit

Permalink
Keep composer cache in local directory
Browse files Browse the repository at this point in the history
  • Loading branch information
piggito committed Aug 31, 2020
1 parent d82a5f3 commit 4745849
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions .env.default
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ IMAGE_REDIS=redis:5-alpine
IMAGE_DRIVER=zenika/alpine-chrome
CLEAR_FRONT_PACKAGES=no
ADD_PHP_EXT=
COMPOSER_HOME_CACHE=.cache/composer
MAIN_DOMAIN_NAME=docker.localhost
DB_URL=sqlite:./../.cache/d8.sqlite
# Faster but data will be lost on php container recreation
Expand Down
2 changes: 1 addition & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ prepare:front:
- echo "CI_PROJECT_NAME=${CI_PROJECT_NAME}"
- echo "REVIEW_DOMAIN=${REVIEW_DOMAIN}"
- mkdir -p ${BUILD_DIR}
- rsync -ah --exclude=.git --delete ./ ${BUILD_DIR}
- rsync -ah --exclude=.git --exclude=.cache --delete ./ ${BUILD_DIR}
- cd ${BUILD_DIR}
- echo "COMPOSE_PROJECT_NAME=${CI_PROJECT_NAME}-review-${CI_COMMIT_REF_SLUG}" >> .env.default
- echo "MAIN_DOMAIN_NAME=${CI_ENVIRONMENT_SLUG}-${CI_PROJECT_PATH_SLUG}.${REVIEW_DOMAIN}" >> .env.default
Expand Down
13 changes: 12 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,22 @@ endif
@echo "Updating containers..."
docker-compose pull
@echo "Build and run containers..."
mkdir -p $(COMPOSER_HOME_CACHE)
docker-compose up -d --remove-orphans
$(call php-0, apk add --no-cache graphicsmagick $(ADD_PHP_EXT))
$(call php-0, sh -c '[ ! -z "$$COMPOSER_HOME" -a -d $$COMPOSER_HOME ] && chown -R $(CUID):$(CGID) $$COMPOSER_HOME')
$(call php-0, kill -USR2 1)
$(call php, composer global require -o --update-no-dev --no-suggest "hirak/prestissimo:^0.3")

## Install backend dependencies
back:
mkdir -p $(COMPOSER_HOME_CACHE)
docker-compose up -d --remove-orphans php # PHP container is required for composer
ifeq ($(INSTALL_DEV_DEPENDENCIES), TRUE)
$(call php-0, apk add --no-cache $(ADD_PHP_EXT))
$(call php-0, sh -c '[ ! -z "$$COMPOSER_HOME" -a -d $$COMPOSER_HOME ] && chown -R $(CUID):$(CGID) $$COMPOSER_HOME')
$(call php-0, kill -USR2 1)
$(call php, composer global require -o --update-no-dev --no-suggest "hirak/prestissimo:^0.3")
ifdef INSTALL_DEV_DEPENDENCIES
@echo "INSTALL_DEV_DEPENDENCIES=$(INSTALL_DEV_DEPENDENCIES)"
@echo "Installing composer dependencies, including dev ones"
$(call php, composer install --prefer-dist -o)
Expand Down Expand Up @@ -146,6 +153,10 @@ ifdef MYSQL_DIR
@echo "Removing mysql data from $(MYSQL_DIR) ..."
docker run --rm --user 0:0 -v $(shell dirname $(MYSQL_DIR)):/mnt $(IMAGE_PHP) sh -c "rm -fr /mnt/`basename $(MYSQL_DIR)`"
endif
ifdef COMPOSER_HOME_CACHE
@echo "Clean-up composer cache from $(COMPOSER_HOME_CACHE) ..."
docker run --rm --user 0:0 -v $(shell dirname $(abspath $(COMPOSER_HOME_CACHE))):/mnt $(IMAGE_PHP) sh -c "rm -fr /mnt/`basename $(COMPOSER_HOME_CACHE)`"
endif
ifeq ($(CLEAR_FRONT_PACKAGES), yes)
make clear-front
endif
Expand Down
2 changes: 2 additions & 0 deletions docker/docker-compose.override.yml.default
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ services:
php:
environment:
COMPOSER_MEMORY_LIMIT: "-1"
COMPOSER_HOME: /home/www-data/.composer
volumes:
- "./90-mail.ini:/etc/php7/conf.d/90-mail.ini:z"
- "../${COMPOSER_HOME_CACHE}:/home/www-data/.composer:z"
# depends_on:
# - mysql
# Uncomment next line if you need PHP XDebug.
Expand Down

0 comments on commit 4745849

Please sign in to comment.