Skip to content

fix: Keep PLATFORM_CACHE_DIR in a per-project volume, fixes #28 - #29

Open
rfay wants to merge 2 commits into
mainfrom
20261122_rfay_platform_cache_volume
Open

rfay wants to merge 2 commits into
mainfrom
20261122_rfay_platform_cache_volume

Conversation

@rfay

@rfay rfay commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

Short Summary (TL;DR)

Moves PLATFORM_CACHE_DIR onto a per-project Docker volume, so build hook caches survive ddev restart on DDEV v1.25.6+, which no longer mounts ddev-global-cache on web.

The Issue

DDEV v1.25.6 stopped mounting ddev-global-cache on web (ddev/ddev#9045). PLATFORM_CACHE_DIR pointed at /mnt/ddev-global-cache/ddev-upsun/<project>, which then lived in the container's own filesystem and was emptied by ddev restart.

How This PR Solves The Issue

  • New docker-compose.upsun.yaml mounts a project volume, upsun-cache, at /mnt/ddev-upsun-cache on web.
  • PLATFORM_CACHE_DIR is now /mnt/ddev-upsun-cache. The volume already belongs to one project, so the /<project> subdirectory is gone.
  • The generated .ddev/web-build/Dockerfile.upsun creates /mnt/ddev-upsun-cache owned by the web user. Docker copies that ownership into the new, empty volume, so build hooks can write to it.

The issue suggested mounting at /mnt/ddev-global-cache/ddev-upsun. This uses a separate path so the volume isn't nested inside ddev-global-cache on DDEV v1.25.5 and older, which still mount it on web.

Manual Testing Instructions

ddev add-on get ddev/ddev-upsun --pr 29
ddev restart
ddev exec 'echo $PLATFORM_CACHE_DIR && touch $PLATFORM_CACHE_DIR/marker'
ddev restart
ddev exec 'ls $PLATFORM_CACHE_DIR'
# marker should still be there

Automated Testing Overview

The unified bats test now writes a marker into $PLATFORM_CACHE_DIR, runs ddev restart, and checks the marker is still there. It also checks that docker-compose.upsun.yaml is installed with the add-on and removed with it.

test-drupal11-mariadb-flex passed locally on DDEV v1.25.5-95-g75bf48681. The other variants were not run locally.

Release/Deployment Notes

  • Existing projects start with an empty cache after this change, because the path moves.
  • Not checked: whether Apple container fills a new volume from the image the way Docker does. If it doesn't, the cache directory may not be writable there.

https://claude.ai/code/session_01UrTUMyt3M2SmDRFaUiqqmb


Generated by Claude Code

DDEV v1.25.6 no longer mounts ddev-global-cache on web (ddev/ddev#9045),
so PLATFORM_CACHE_DIR under /mnt/ddev-global-cache was lost on
`ddev restart`.

- Add docker-compose.upsun.yaml mounting an upsun-cache project volume
  at /mnt/ddev-upsun-cache
- Point PLATFORM_CACHE_DIR at /mnt/ddev-upsun-cache
- Create the mount point owned by the web user in Dockerfile.upsun so
  the new volume is writable
- Test that the cache survives `ddev restart`

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UrTUMyt3M2SmDRFaUiqqmb
The postgres fixture's DB dump doesn't match config/sync, so its deploy
hook's drush config-import fails on any restart after the DB import.
The restart only checks that the cache volume persists.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UrTUMyt3M2SmDRFaUiqqmb
rfay pushed a commit that referenced this pull request Nov 22, 2026
## Short Summary (TL;DR)

The Postgres test DB dump now matches the shared `config/sync`, so the deploy hook's `drush config-import` passes on `ddev restart` of a Postgres test project.

## The Issue

`tests/per_test.sh` imports `db-postgres.sql.gz` for Postgres variants. The dump didn't match `config/sync`. On `ddev restart`, the deploy hook runs `drush config-import`, which failed with these errors:

- Site UUID in source storage does not match the target storage.
- Unable to uninstall the PostgreSQL module, because it provides the `pgsql` database driver.
- Entities exist of type ... need to be deleted before importing.

The first `ddev start` doesn't hit this, because the DB is imported after it. A restart of `test-drupal11-postgres-flex` failed its post-start hook.

## How This PR Solves The Issue

- `settings.php` sets `$settings['config_exclude_modules'] = ['mysql', 'pgsql']`. The MySQL/MariaDB and Postgres variants share one `config/sync`, so config import and export now leave the database driver modules alone.
- `db-postgres.sql.gz` is regenerated on Postgres 17:
  1. A `demo_umami` install, plus the other modules in `core.extension.yml`.
  2. The site UUID and every config entity UUID set to the values in `config/sync`.
  3. `drush config-import`, after which a second import reports no changes.
  4. Cache, session and watchdog tables emptied before the dump.

## Manual Testing Instructions

```bash
git clone https://github.com/ddev/ddev-upsun && cd ddev-upsun
gh pr checkout 30
bats tests/drupal11-unified.bats -f 'test-drupal11-postgres-flex$'
# Expect: ok 1 test-drupal11-postgres-flex
```

To check the restart by hand, run these from the `ddev-upsun` checkout:

```bash
REPO=$PWD && mkdir -p ~/tmp/pgtest && cd ~/tmp/pgtest
cp -r $REPO/tests/testdata/drupal11-base/. . && cp -r $REPO/tests/testdata/platform-configs/postgres-flex/. .
ddev config --project-type=drupal11 --docroot=web --fail-on-hook-fail --web-environment-add=PLATFORM_PROJECT=test,PLATFORM_ENVIRONMENT=test
ddev add-on get $REPO
ddev start -y
ddev composer install --no-dev --no-interaction
ddev import-db --file=db-postgres.sql.gz
ddev restart
# Expect the deploy hook to run config-import without errors
```

## Automated Testing Overview

Claude Code ran these on Linux, each passing:

- `bats tests/drupal11-unified.bats -f 'test-drupal11-postgres-flex$'`
- The postgres, mariadb and mysql flex tests with a `ddev restart` check that runs the deploy hook under `--fail-on-hook-fail`.

Nobody ran the fixed-format variants or macOS.

## Release/Deployment Notes

This PR changes only test fixtures. #29 can drop `--skip-hooks` from its restart check after this merges.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01UrTUMwxMkiE5j9dzeKy8rR

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UrTUMwxMkiE5j9dzeKy8rR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PLATFORM_CACHE_DIR is lost on ddev restart with DDEV v1.25.6

2 participants