Important
This repository has been integrated with a new combined pre-award-stores.
This repository is designed to handle the generating and providing of JSON payloads for accounts.
This service depends on:
- A postgres database
- No other microservices
A number of Flask environment config setups exist, including default, development, dev, test, production and unit_test configurations.
Depending on where you are running this you may need to set particular environment variables that are declared in these config files in config/envs eg. host names etc. More generally though you can switch between these environment configs using the FLASK_ENV
environment variable. This has been set in the .flaskenv
to FLASK_ENV=development
so you shouldn't need to set that if running locally, but you will need to set that elsewhere to ensure it uses the correct config file for the environment you want it to run in.
This application requires a postgres database.
General instructions for local db development are available here: Local database development
When creating the database you either manually create a database called fsd_account_store_dev
or use the provided invoke script which can be run from the root directory with
invoke bootstrap_dev_db
Once you have created the database you need to set the DATABASE_URL
environment variable so the application knows where to find it.
This url can be set in the .flaskenv
file in the root as
# pragma: allowlist nextline secret
DATABASE_URL==postgresql://postgres:postgres@127.0.0.1:5432/fsd_account_store_dev
...so if you are running locally on a development machine and you have used the invoke bootstrap_dev_db
script above to create the database, it should just connect automatically.
If running elsewhere you will need to set the DATABASE_URL env var to the correct url eg. with export DATABASE_URL=<your-database-url>
NOTE: during testing with pytest a separate database is created for unit tests to run against. This is then deleted after the tests have run.
Once you have the database running and have the flask application configured to connect to it, you then need to run the database migrations to create the required tables etc. This is outlined in the Local database development README above.
Enter the virtual environment as described above, then:
flask run
You can run this api using a docker container. To build a image run the following command:
docker build -t fsd_account_store .
Paketo is used to build the docker image which gets deployed to our test and production environments. Details available here
envs
needs to include values for each of:
SENTRY_DSN
GITHUB_SHA
DATABASE_URL
- Ensure you have a local postgres instance setup and running with a user
postgres
created. - Ensure that you have set a DATABASE_URL environment variable.
- Activate your virtual env:
source .venv/bin/activate
- Install
requirements-dev.txt
- Run pytest
NB : pytest will create a database with a unique name to use just for unit tests. Changes to this db from tests does not persist.
Test data is created on a per-test basis to prevent test pollution. To create test data for a test, request the seed_test_data
fixture in your test. That fixture then provides access to the inserted records and will clean up after itself at the end of the test session.
More details on the fixtures in utils: https://github.com/communitiesuk/funding-service-design-utils/blob/dcc64b0b253a1056ce99e8fe7ea8530406355c96/README.md#fixtures
Details on how our pipelines work and the release process is available here
Copilot is used for infrastructure deployment. Instructions are available here, with the following values for the account store:
- service-name: fsd-account-store
- image-name: ghcr.io/communitiesuk/funding-service-design-account-store:latest