Local Setup
Before you start
You can use the pre-configured devcontainers in the .devcontainer directory to get started quickly.
You will need:
- Git
git --version - Docker with Compose
docker -v - Node.js, the version in
.nvmrcnode -v - PHP 8.2
php -v - Composer
composer -V - AWS CLI
aws --version
Getting started
-
Clone the repository
git clone git@github.com:dvsa/vol-app.git -
Change into the project directory
cd vol-appwarningIf you are resetting the database you will need to be be authenticated with the AWS VOL
nonprodaccount.If you have the ZSH AWS plugin installed & configured, you can run the following command to get temporary credentials:
acp [profile]
Running the app
If you have nvm installed, use nvm use to switch to the Node.js version in .nvmrc.
-
Install the NPM dependencies in the root directory
npm install -
Add DNS entries to your
/etc/hostsfilewarningYou only need to do this once.
sudo echo "127.0.0.1 iuweb.local.olcs.dev-dvsacloud.uk ssweb.local.olcs.dev-dvsacloud.uk api.local.olcs.dev-dvsacloud.uk cdn.local.olcs.dev-dvsacloud.uk mailpit.local.olcs.dev-dvsacloud.uk" >> /etc/hosts -
Start the application
warningThe
olcs-etlproject needs to be mounted as a volume in thedbcontainer. By default, the directory is set to../olcs-etl.You can customise this using the
OLCS_ETL_DIRenvironment variable before running thedocker composecommand.export OLCS_ETL_DIR=/path/to/olcs-etldocker compose up -d -
Run the local setup script - this script will also as a local reset and is safe to run multiple times.
infoIf this is the first time you are running the application, you will need to run all the steps.
npm run refreshAWS Configuration SyncThe refresh script includes an AWS Secrets and Parameters sync step that automatically updates your local PHP configuration files with values from AWS.
For detailed information about configuring this sync, see AWS Secrets and Parameters Sync.
Updating test snapshotsThe last two steps regenerate the API request validation (DTO) snapshots and the form specification snapshots, after you have deliberately changed a DTO or a form. They are off by default; leave them off for a normal refresh. They use the packages already installed on your machine, and the Composer step above does not install the libraries, so run
composer updateinlib/olcs-transfer,lib/olcs-authandlib/olcs-commonfirst or you may write snapshots that fail in CI. See API request validation snapshot and Form specification snapshot.
All done!
You can visit the application in your browser:
Any email sent by the app can be viewed via: Mailpit
Logging in
The local dataset has a number of different users that you can log in as.
The default password for all users while using LDAP is Password1.
Selfserve
| Username | Role |
|---|---|
usr542 | Operator - User |
usr543 | Operator - Transport Manager |
usr611 | Operator - Admin |
usr612 | Operator - Admin |
usr778 | Partner - Admin |
usr779 | Partner - Admin |
usr1964 | Partner - User |
usr1965 | Partner - User |
usr20131 | Local Authority administrator |
usr20132 | Local Authority user |
Internal
| Username | Role |
|---|---|
usr20 | Case worker |
usr21 | Case worker |
usr59 | Admin |
usr273 | Admin |
usr291 | System Admin |
usr322 | Admin |
usr331 | Limited read only |
usr342 | Limited read only |
usr455 | Admin |
usr528 | Read only |
usr529 | Read only |
usr1071 | Admin |
usr29431 | IRHP Admin |
usr36047 | Admin |
usr39158 | Admin |
usr68648 | Admin |
usr73852 | Admin |
usr76189 | Admin |
usr76754 | Admin |
In the event that the local dataset changes, the above tables can be reproduced using the SQL:
SELECT u.login_id, r.description, IF(u.team_id IS NULL, "Selfserve", "Internal") as tenant FROM user u JOIN user_role ur ON u.id = ur.user_id JOIN role r ON r.id = ur.role_id;
Development settings
The development images keep OPcache on and Xdebug off, they cache the merged Laminas configuration, and they don't start ClamAV, so pages stay quick even through the bind-mounted source. The settings below switch on the slower tools when you need them.
The "Change the development settings?" step of npm run refresh asks for each setting, writes your answers to the .env file in the repository root and recreates the PHP containers so they take effect. You can also edit .env yourself (Git ignores it, and Docker Compose reads it automatically), then run docker compose up -d to apply it.
# .env
XDEBUG_MODE=debug
VOL_DEVTOOLS=1
| Setting | Default | What it does |
|---|---|---|
XDEBUG_MODE | off | The Xdebug mode, for example debug or coverage. With debug, every request connects to your IDE on port 9003. Xdebug slows every request down while it's on, even when the IDE isn't listening, so turn it back off. |
VOL_DEVTOOLS | 0 | Loads the Laminas developer toolbar and the session toolbar in selfserve and internal. It also adds over 500 KB to every page. |
VOL_CONFIG_CACHE | 1 | Caches the merged Laminas configuration in each app's data/cache. Merging it is the slowest part of a request, so turning the cache off roughly triples page times. Set it to 0 if you suspect the cache. |
The configuration cache follows your changes. It is named after everything it was built from: the files in each app's config and module/*/config and the libraries' config, the Module.php classes, any other class the configuration uses while it's merged (such as SectionConfig, the API route helpers or RefData), and the Composer packages. Editing or deleting one of those files, switching branch or running composer install rebuilds it on the next request. Recreating a container rebuilds it too, which is how a change to .env takes effect. A brand-new configuration file, such as a new route file in a directory that is loaded with glob(), can take up to 2 seconds to be picked up. Command-line runs in the cli container don't use the cache.
VOL_DEVTOOLS and VOL_CONFIG_CACHE are read by each app's config/development.config.php, your copy of development.config.php.dist. If your copy predates these settings, copy the dist file again with the "Copy the Laminas configuration dist files" step of npm run refresh; until you do, the toolbar stays on and the configuration isn't cached.
If PHP can't write to an app's data/cache, the app runs without the configuration cache and says so in its container's log (docker compose logs api). This can happen on Linux, where the bind-mounted directory belongs to your user rather than the container's.
To use Xdebug for a single command without restarting anything, pass the mode to docker compose exec or to php:
docker compose exec -e XDEBUG_MODE=debug cli vendor/bin/laminas <command>
docker compose exec api php -d xdebug.mode=coverage vendor/bin/phpunit --coverage-text
The PHP settings behind all of this are in infra/docker/php-development.d/development.ini, which compose.yaml mounts into the four PHP containers. After changing it, run docker compose restart api cli selfserve internal. OPcache is only on for web requests: on the command line every process would compile into a cache of its own, so tests and Composer run without it.
Virus scanning
ClamAV is installed in the selfserve and internal images but not started, because local.php.dist switches virus scanning off and clamd holds about 1 GB of signatures in memory. To test scanning locally, remove the antiVirus override from that app's config/autoload/local.php and start the daemon, which takes a few seconds to load:
docker compose exec -d selfserve clamd # or internal
Restarting the container stops it again.
Mock GOV.UK One Login and address lookup
A local stack can't reach GOV.UK One Login's integration environment or the DVSA Address Service without credentials and a route to them. compose-mocks.yaml adds a stand-in for both: one container, from docker/mock-govuk-signin in dvsa/vol-terraform, that answers as mocksignin.local.olcs.dev-dvsacloud.uk and mockaddress.local.olcs.dev-dvsacloud.uk. It also points the API at them, through app/api/config/autoload/mocks.global-development.php, which is only loaded in development and only does anything in containers started with this file.
-
Check out
vol-terraformnext to this repository, as../vol-terraform. Compose builds the mock from that copy the first time it starts. If yours is somewhere else, setVOL_TERRAFORM_DIRto its path in the.envfile in the repository root. If Compose can't find it, it stops with an error about the build context or about "additional privileges requested". -
Add the sign-in mock to the line you added to
/etc/hosts, because your browser is sent to it:127.0.0.1 mocksignin.local.olcs.dev-dvsacloud.uk -
Start the stack with both files:
docker compose -f compose.yaml -f compose-mocks.yaml up -dTo have every
docker composecommand use both, addCOMPOSE_FILE=compose.yaml:compose-mocks.yamlto the root.envfile. To go back, leave the second file out and rundocker compose up -d --remove-orphans. -
For address lookups, switch the
use_new_address_servicefeature toggle on (internal: Admin, then Feature toggles). With it off, the API uses the old address service.
Sign in as any of the mock's test users, which http://mocksignin.local.olcs.dev-dvsacloud.uk/mock-info lists. Your app/api/config/autoload/local.php still needs a client_id and signing keys under govuk_account: the mock accepts any, but the API can't start a sign-in without them.
The postcodes the address mock knows, by traffic area, are in docker/mock-govuk-signin/README.md in vol-terraform. Any other full postcode finds no addresses.
After pulling vol-terraform, rebuild the mock with docker compose -f compose.yaml -f compose-mocks.yaml build mock-govuk-signin.
Troubleshooting
Containers lose the in-tree lib mounts after composer install
The PHP services (api, cli, selfserve, internal) bind-mount the in-tree
shared libraries (./lib/olcs-*) over their vendor/olcs/* paths so live edits
work on both host and container. Running composer install/update on the
host recreates those vendor/olcs/* symlinks, which detaches the running
container's bind mounts. Symptoms include module init failures
(Module (Dvsa\Olcs\Transfer) could not be initialized), "class not found"
errors for Dvsa\Olcs\* lib classes, or Invalid argument when listing the
vendor path inside the container.
Recreate the affected container (a plain restart will not re-establish the
mounts):
docker compose up -d --force-recreate cli # or api / selfserve / internal