Steps to run MOJ Form app locally
Namespacing
Docker Containerisation
Run MOJ forms locally via Docker
Goals
Group containers into functional networks:
app-netโ app + api + workers + metadata + token cachedb-netโ Postgres/Redis, shared only with the services that need them
Expose only the ports your host actually needs (usually zero for internal services).
Prevent containers from accessing services they shouldn’t.
Repositories involved
The following repositories may need changes during this process:
fb-user-datastorefb-editorfb-metadata-apifb-submitter- the services in
fb-runner(note:fb-runnerdoes not have its own database) hmcts-complaints-formbuilder-adapter
Applications
fb-editor
Services
- editor-app, editor-workers
- editor-db
- editor-metadata-api
- editor-metadata-db
- editor-service-token-cache-api
- editor-service-token-cache-redis
Command
make setup
URL
fb-runner
Services
- runner-app
- runner-service-token-cache-api
- runner-service-token-cache-redis
- user-datastore-api
- user-datastore-db
- user-filestore-api
- localstack
Command
make setup
URL
fb-submitter
Services
- submitter-api, submitter-worker
- submitter-db
- pdf-generator-api
Command
make setup
fb-metadata-presenter
Rails engine responsible for rendering the MoJ Form Builder metadata into Welcome to GOV.UK design system components.
Notes:
Update env variable LOCALSTACK_AUTH_TOKEN while setting up fb-runner. Use a valid
token taken from a LocalStack account. This token must never be pushed to GitHub โ
it is for local testing only.
Testing changes to fb-user-datastore with fb-runner
To exercise local fb-user-datastore changes through fb-runner:
- Push your
fb-user-datastorechanges to a branch on GitHub. The localfb-runnerservice config references the branch, so the changes must be available remotely for runner to pick them up. - Point the local
fb-runnerservice config at that branch. - Run
fb-runnerlocally withmake setup, using the new Docker Postgres. - Open http://localhost:9000/ and complete a form that includes an upload file feature.
- Attempt to submit the form.
The “The specified bucket does not exist” error below will sometimes arise when attempting to confirm an uploaded file.
Troubleshooting
Error: “The specified bucket does not exist”
user-filestore-api | [UploadsController] Unexpected error: The specified bucket does not exist
user-filestore-api | Completed 503 Service Unavailable in 437ms (Views: 0.3ms | Allocations: 163352)
Solution: Execute the following command from localstack-main container
docker exec -it localstack-main /bin/sh -c "awslocal s3api create-bucket --bucket moj-formbuilder"
For development and test environments disable the following lines from Dockerfile to reflect the file changes
RUN bundle config set deployment true
RUN bundle config set without 'test development'
๐ What This Achieves
๐ Security
No external access to:
- Postgres
- Redis
- Metadata API
- Service Token Cache API
- User Data store API
- User File store API
- Submitter API
- PDF Generator API
- Workers
Only the main app is reachable from your laptop or browser.
๐ Performance
Network cross-talk is limited.
๐งผ Cleaner Dev UX
No more Port Mapping.
๐งฉ Separation of concerns
app-net: application business logicdb-net: persistence layer

