# Local Docker environment

Services: Apache + PHP 8.3 (`app`), MariaDB 11.4, OpenSearch 2.19, Valkey (Redis), Mailpit.

## First run

1. Make sure `app/etc/env.php` exists. Copy it from dev or staging if it doesn't: it holds the crypt key, and that key must match the database dump.
2. Get a database dump (`.sql` or `.sql.gz`).
3. From Git Bash or WSL:

   ```bash
   bash docker/setup.sh path/to/dump.sql.gz
   ```

   This starts the containers, imports the dump, backs up your `env.php` to `app/etc/env.php.pre-docker`, points `env.php` and the base URLs at Docker, and then runs `setup:upgrade`, the reindex and a cache flush.
4. Create an admin user: `bash docker/magento.sh admin:user:create`

| What | URL |
|---|---|
| Store / GraphQL | http://localhost:8080/ , http://localhost:8080/graphql |
| Admin | http://localhost:8080/admin_sgroup |
| Mailpit (all outgoing mail) | http://localhost:8025 |
| DB from PhpStorm | localhost:3307, user `magento` / `magento`, database `magento` |

## Day to day

```bash
docker compose up -d                 # start
docker compose down                  # stop (data is kept in volumes)
bash docker/magento.sh cache:flush   # any bin/magento command
docker compose exec -u www-data app bash
```

To go back to your previous setup outside Docker: `cp app/etc/env.php.pre-docker app/etc/env.php`

## Options (`.env` file at the project root)

```
HTTP_PORT=8080
DB_PORT=3307
MAILPIT_PORT=8025
XDEBUG_MODE=debug     # default: off. In PhpStorm, create a server named "sherpa-docker" and map the project root to /var/www/html
```

## Notes

- **Performance on Windows:** Magento is very slow when the code is bind-mounted from `C:\`. For usable speed, clone the repo inside WSL2 (for example `\\wsl$\Ubuntu\home\<you>\...`) and run everything from there.
- The local `vendor/` is used as is, so the manual vendor patches listed in the root README carry over. If `vendor/` is missing, setup runs `composer install`, and you then have to re-apply those patches.
- Cron does not run, so production integrations are not triggered. All mail goes to Mailpit.
