GOV.UK Notify template preview service. Generates PNG and PDF previews of letter templates created in the GOV.UK Notify admin app.
Since it's run in docker on PaaS, it's recommended that you use docker to run this locally.
make prepare-docker-build-image
This will create the docker container and install the dependencies.
These can only be run when the app is not running due to port clashes
make test-with-docker
This script will run all the tests. py.test is used for testing.
Running tests will also apply syntax checking, using pycodestyle.
make run-with-docker
Then visit your app at http://localhost:6013/
. For authenticated endpoints, HTTP Token Authentication is used - by default, locally it's set to my-secret-key
.
If you want to run this locally, follow these instructions:
curl \
-X POST \
-H "Authorization: Token my-secret-key" \
-H "Content-type: application/json" \
-d '{
"template":{
"subject": "foo",
"content": "bar"
},
"values": null,
"letter_contact_block": "baz",
"dvla_org_id": "001"
}'
http://localhost:6013/preview.pdf
You shouldn’t need to deploy this manually because there’s a pipeline setup in Jenkins. If you do want to deploy it manually, you'll need the notify-credentials repo set up locally.
make (sandbox|preview|staging|production) upload-to-dockerhub
make (sandbox|preview|staging|production) cf-deploy
During development it may be preferable to run locally.
If you haven't installed the app yet follow these steps -
# binary dependencies
brew install imagemagick@6 ghostscript cairo pango
brew link --force imagemagick@6
mkvirtualenv -p /usr/local/bin/python3 notifications-template-preview
pip install -r requirements.txt
# create a version file
make _generate-version-file
You will also need to set VCAP_SERVICES (extracted from Makefile) -
export VCAP_SERVICES='{"user-provided":[{"credentials":{"api_host": "some_domain","api_key":"my-secret-key"},"label":"user-provided","name":"notify-template-preview","syslog_drain_url":"","tags":[],"volume_mounts":[]}]}'
Then call the run app script -
./scripts/run_app.sh 6013
Thereafter activate the virtualenv prior to executing the run app script above -
workon notifications-template-preview