Skip to content

Keep composer cache in local directory #278

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env.default
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ IMAGE_DRIVER=zenika/alpine-chrome
CLEAR_FRONT_PACKAGES=no
ADD_PHP_EXT=
#ADD_PHP_EXT=php7-pdo_pgsql postgresql-client postgresql-contrib gnu-libiconv wkhtmltopdf
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
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,23 @@ 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 tzdata $(ADD_PHP_EXT))
# Set up timezone
$(call php-0, cp /usr/share/zoneinfo/Europe/Paris /etc/localtime)
$(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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any reason to duplicate provision goal here?

docker-compose up -d --remove-orphans --no-deps php # PHP container is required for composer
ifneq ($(strip $(ADD_PHP_EXT)),)
# Install additional php extensions as this goal used in CI (todo stop doing it)
$(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')
endif
ifeq ($(INSTALL_DEV_DEPENDENCIES), TRUE)
@echo "INSTALL_DEV_DEPENDENCIES=$(INSTALL_DEV_DEPENDENCIES)"
Expand Down Expand Up @@ -156,6 +160,10 @@ ifdef DB_MOUNT_DIR
@echo "Clean-up database data from $(DB_MOUNT_DIR) ..."
docker run --rm --user 0:0 -v $(shell dirname $(DB_MOUNT_DIR)):/mnt $(IMAGE_PHP) sh -c "rm -fr /mnt/`basename $(DB_MOUNT_DIR)`"
endif
ifdef COMPOSER_HOME_CACHE
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cache should not be cleared as it will be shared in CI

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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,11 +6,13 @@ services:
php:
environment:
COMPOSER_MEMORY_LIMIT: "-1"
COMPOSER_HOME: /home/www-data/.composer
# BLACKFIRE_CLIENT_ID: x
# BLACKFIRE_CLIENT_TOKEN: x
# NEW_RELIC_LICENSE_KEY: x
# NEW_RELIC_APPNAME: "${COMPOSE_PROJECT_NAME}"
volumes:
- "${COMPOSER_HOME_CACHE}:/home/www-data/.composer:z"
- "./90-mail.ini:/etc/php7/conf.d/90-mail.ini:z"
# depends_on:
# - mysql
Expand Down