Skip to content

Commit 4745849

Browse files
committed
Keep composer cache in local directory
1 parent d82a5f3 commit 4745849

File tree

4 files changed

+16
-2
lines changed

4 files changed

+16
-2
lines changed

.env.default

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ IMAGE_REDIS=redis:5-alpine
1818
IMAGE_DRIVER=zenika/alpine-chrome
1919
CLEAR_FRONT_PACKAGES=no
2020
ADD_PHP_EXT=
21+
COMPOSER_HOME_CACHE=.cache/composer
2122
MAIN_DOMAIN_NAME=docker.localhost
2223
DB_URL=sqlite:./../.cache/d8.sqlite
2324
# Faster but data will be lost on php container recreation

.gitlab-ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ prepare:front:
179179
- echo "CI_PROJECT_NAME=${CI_PROJECT_NAME}"
180180
- echo "REVIEW_DOMAIN=${REVIEW_DOMAIN}"
181181
- mkdir -p ${BUILD_DIR}
182-
- rsync -ah --exclude=.git --delete ./ ${BUILD_DIR}
182+
- rsync -ah --exclude=.git --exclude=.cache --delete ./ ${BUILD_DIR}
183183
- cd ${BUILD_DIR}
184184
- echo "COMPOSE_PROJECT_NAME=${CI_PROJECT_NAME}-review-${CI_COMMIT_REF_SLUG}" >> .env.default
185185
- echo "MAIN_DOMAIN_NAME=${CI_ENVIRONMENT_SLUG}-${CI_PROJECT_PATH_SLUG}.${REVIEW_DOMAIN}" >> .env.default

Makefile

+12-1
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,22 @@ endif
6666
@echo "Updating containers..."
6767
docker-compose pull
6868
@echo "Build and run containers..."
69+
mkdir -p $(COMPOSER_HOME_CACHE)
6970
docker-compose up -d --remove-orphans
7071
$(call php-0, apk add --no-cache graphicsmagick $(ADD_PHP_EXT))
72+
$(call php-0, sh -c '[ ! -z "$$COMPOSER_HOME" -a -d $$COMPOSER_HOME ] && chown -R $(CUID):$(CGID) $$COMPOSER_HOME')
7173
$(call php-0, kill -USR2 1)
7274
$(call php, composer global require -o --update-no-dev --no-suggest "hirak/prestissimo:^0.3")
7375

7476
## Install backend dependencies
7577
back:
78+
mkdir -p $(COMPOSER_HOME_CACHE)
7679
docker-compose up -d --remove-orphans php # PHP container is required for composer
77-
ifeq ($(INSTALL_DEV_DEPENDENCIES), TRUE)
80+
$(call php-0, apk add --no-cache $(ADD_PHP_EXT))
81+
$(call php-0, sh -c '[ ! -z "$$COMPOSER_HOME" -a -d $$COMPOSER_HOME ] && chown -R $(CUID):$(CGID) $$COMPOSER_HOME')
82+
$(call php-0, kill -USR2 1)
83+
$(call php, composer global require -o --update-no-dev --no-suggest "hirak/prestissimo:^0.3")
84+
ifdef INSTALL_DEV_DEPENDENCIES
7885
@echo "INSTALL_DEV_DEPENDENCIES=$(INSTALL_DEV_DEPENDENCIES)"
7986
@echo "Installing composer dependencies, including dev ones"
8087
$(call php, composer install --prefer-dist -o)
@@ -146,6 +153,10 @@ ifdef MYSQL_DIR
146153
@echo "Removing mysql data from $(MYSQL_DIR) ..."
147154
docker run --rm --user 0:0 -v $(shell dirname $(MYSQL_DIR)):/mnt $(IMAGE_PHP) sh -c "rm -fr /mnt/`basename $(MYSQL_DIR)`"
148155
endif
156+
ifdef COMPOSER_HOME_CACHE
157+
@echo "Clean-up composer cache from $(COMPOSER_HOME_CACHE) ..."
158+
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)`"
159+
endif
149160
ifeq ($(CLEAR_FRONT_PACKAGES), yes)
150161
make clear-front
151162
endif

docker/docker-compose.override.yml.default

+2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ services:
66
php:
77
environment:
88
COMPOSER_MEMORY_LIMIT: "-1"
9+
COMPOSER_HOME: /home/www-data/.composer
910
volumes:
1011
- "./90-mail.ini:/etc/php7/conf.d/90-mail.ini:z"
12+
- "../${COMPOSER_HOME_CACHE}:/home/www-data/.composer:z"
1113
# depends_on:
1214
# - mysql
1315
# Uncomment next line if you need PHP XDebug.

0 commit comments

Comments
 (0)