Skip to main content

Local Setup

Before you start​

tip

You can use the pre-configured devcontainers in the .devcontainer directory to get started quickly.

You will need:

Getting started​

  1. Clone the repository

    git clone git@github.com:dvsa/vol-app.git
  2. Change into the project directory

    cd vol-app
    warning

    If you are resetting the database you will need to be be authenticated with the AWS VOL nonprod account.

    If you have the ZSH AWS plugin installed & configured, you can run the following command to get temporary credentials:

    acp [profile]

Running the app​

tip

If you have nvm installed, use nvm use to switch to the Node.js version in .nvmrc.

  1. Install the NPM dependencies in the root directory

    npm install
  2. Add DNS entries to your /etc/hosts file

    warning

    You 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
  3. Start the application

    warning

    The olcs-etl project needs to be mounted as a volume in the db container. By default, the directory is set to ../olcs-etl.

    You can customise this using the OLCS_ETL_DIR environment variable before running the docker compose command.

    export OLCS_ETL_DIR=/path/to/olcs-etl
    docker compose up -d
  4. Run the local setup script - this script will also as a local reset and is safe to run multiple times.

    info

    If this is the first time you are running the application, you will need to run all the steps.

    npm run refresh
    AWS Configuration Sync

    The 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 snapshots

    The 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 update in lib/olcs-transfer, lib/olcs-auth and lib/olcs-common first or you may write snapshots that fail in CI. See API request validation snapshot and Form specification snapshot.

success

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.

info

The default password for all users while using LDAP is Password1.

Selfserve​

UsernameRole
usr542Operator - User
usr543Operator - Transport Manager
usr611Operator - Admin
usr612Operator - Admin
usr778Partner - Admin
usr779Partner - Admin
usr1964Partner - User
usr1965Partner - User
usr20131Local Authority administrator
usr20132Local Authority user

Internal​

UsernameRole
usr20Case worker
usr21Case worker
usr59Admin
usr273Admin
usr291System Admin
usr322Admin
usr331Limited read only
usr342Limited read only
usr455Admin
usr528Read only
usr529Read only
usr1071Admin
usr29431IRHP Admin
usr36047Admin
usr39158Admin
usr68648Admin
usr73852Admin
usr76189Admin
usr76754Admin
info

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
SettingDefaultWhat it does
XDEBUG_MODEoffThe 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_DEVTOOLS0Loads the Laminas developer toolbar and the session toolbar in selfserve and internal. It also adds over 500 KB to every page.
VOL_CONFIG_CACHE1Caches 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.

  1. Check out vol-terraform next to this repository, as ../vol-terraform. Compose builds the mock from that copy the first time it starts. If yours is somewhere else, set VOL_TERRAFORM_DIR to its path in the .env file in the repository root. If Compose can't find it, it stops with an error about the build context or about "additional privileges requested".

  2. 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
  3. Start the stack with both files:

    docker compose -f compose.yaml -f compose-mocks.yaml up -d

    To have every docker compose command use both, add COMPOSE_FILE=compose.yaml:compose-mocks.yaml to the root .env file. To go back, leave the second file out and run docker compose up -d --remove-orphans.

  4. For address lookups, switch the use_new_address_service feature 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