Skip to content

Commit 6eec60a

Browse files
piggitoandypost
authored andcommitted
Keep composer cache in local directory
1 parent e53e8bd commit 6eec60a

File tree

4 files changed

+12
-1
lines changed

4 files changed

+12
-1
lines changed

.env.default

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ IMAGE_DRIVER=zenika/alpine-chrome
1919
CLEAR_FRONT_PACKAGES=no
2020
ADD_PHP_EXT=
2121
#ADD_PHP_EXT=php7-pdo_pgsql postgresql-client postgresql-contrib gnu-libiconv wkhtmltopdf
22+
COMPOSER_HOME_CACHE=../.cache/composer
2223
MAIN_DOMAIN_NAME=docker.localhost
2324
DB_URL=sqlite:./../.cache/d8.sqlite
2425
# Faster but data will be lost on php container recreation

.gitlab-ci.yml

Lines changed: 1 addition & 1 deletion
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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,19 +70,23 @@ endif
7070
@echo "Updating containers..."
7171
docker-compose pull
7272
@echo "Build and run containers..."
73+
mkdir -p $(COMPOSER_HOME_CACHE)
7374
docker-compose up -d --remove-orphans
7475
$(call php-0, apk add --no-cache graphicsmagick tzdata $(ADD_PHP_EXT))
7576
# Set up timezone
7677
$(call php-0, cp /usr/share/zoneinfo/Europe/Paris /etc/localtime)
78+
$(call php-0, sh -c '[ ! -z "$$COMPOSER_HOME" -a -d $$COMPOSER_HOME ] && chown -R $(CUID):$(CGID) $$COMPOSER_HOME')
7779
$(call php-0, kill -USR2 1)
7880
$(call php, composer global require -o --update-no-dev --no-suggest "hirak/prestissimo:^0.3")
7981

8082
## Install backend dependencies
8183
back:
84+
mkdir -p $(COMPOSER_HOME_CACHE)
8285
docker-compose up -d --remove-orphans --no-deps php # PHP container is required for composer
8386
ifneq ($(strip $(ADD_PHP_EXT)),)
8487
# Install additional php extensions as this goal used in CI (todo stop doing it)
8588
$(call php-0, apk add --no-cache $(ADD_PHP_EXT))
89+
$(call php-0, sh -c '[ ! -z "$$COMPOSER_HOME" -a -d $$COMPOSER_HOME ] && chown -R $(CUID):$(CGID) $$COMPOSER_HOME')
8690
endif
8791
ifeq ($(INSTALL_DEV_DEPENDENCIES), TRUE)
8892
@echo "INSTALL_DEV_DEPENDENCIES=$(INSTALL_DEV_DEPENDENCIES)"
@@ -156,6 +160,10 @@ ifdef DB_MOUNT_DIR
156160
@echo "Clean-up database data from $(DB_MOUNT_DIR) ..."
157161
docker run --rm --user 0:0 -v $(shell dirname $(DB_MOUNT_DIR)):/mnt $(IMAGE_PHP) sh -c "rm -fr /mnt/`basename $(DB_MOUNT_DIR)`"
158162
endif
163+
ifdef COMPOSER_HOME_CACHE
164+
@echo "Clean-up composer cache from $(COMPOSER_HOME_CACHE) ..."
165+
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)`"
166+
endif
159167
ifeq ($(CLEAR_FRONT_PACKAGES), yes)
160168
make clear-front
161169
endif

docker/docker-compose.override.yml.default

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ services:
66
php:
77
environment:
88
COMPOSER_MEMORY_LIMIT: "-1"
9+
COMPOSER_HOME: /home/www-data/.composer
910
# BLACKFIRE_CLIENT_ID: x
1011
# BLACKFIRE_CLIENT_TOKEN: x
1112
# NEW_RELIC_LICENSE_KEY: x
1213
# NEW_RELIC_APPNAME: "${COMPOSE_PROJECT_NAME}"
1314
volumes:
15+
- "${COMPOSER_HOME_CACHE}:/home/www-data/.composer:z"
1416
- "./90-mail.ini:/etc/php7/conf.d/90-mail.ini:z"
1517
# depends_on:
1618
# - mysql

0 commit comments

Comments
 (0)