This repository is part of the Pharos project which is split into three repositories:
Repository | Purpose |
---|---|
pharos-frontend |
Frontend application and deployment infrastructure |
pharos-api |
API and deployment infrastructure |
pharos-database |
SQL database and deployment infrastructure |
pharos-documentation |
Markdown files used to generate about pages |
Click the badges below to view more information about builds on that branch. Changes pushed to any CI/CD branch will automatically be deployed to the corresponding environment.
- Install AWS CLI
- Configure AWS SSO using the Pharos AWS Access Portal
- Install AWS SAM CLI
- Create a development stack using the following command:
sam sync \
--stack-name pharos-api-[DEVELOPER_NAME]-dev \
--region us-east-2
Argument | Source |
---|---|
--stack-name |
Naming convention: pharos-api-[DEVELOPER_NAME]-dev |
--region |
us-east-2 because the API and pharos-database should be in the same region |
--profile |
Optional, if [default] profile is set. Configure AWS SSO using the Pharos AWS Access Portal |
This will deploy a new pharos
stack, and output the Api url, ClientId, and UserPoolId which should be passed to the pharos-frontend develop command.
Additional arguments for the sam sync
command can be found here.
This command will start a docker container called pharos-pytest-database
which
is intended to be a completely throwaway database (will not persist data on shutdown)
only for running local tests using pytest.
The database will be populated with records during the course of running tests as necessary.
docker run --rm \
-P -p 127.0.0.1:5432:5432 \
-e POSTGRES_PASSWORD="1234" \
-e POSTGRES_DB="pharos-pytest" \
--name pharos-pytest-database \
postgis/postgis
python3.9 -m venv env .
source env/bin/activate
pip install -r dev-requirements.txt
source env/bin/activate
pytest -v --cov=src/libraries/python/
This command also creates and displays a coverage report, the full interactive coverage report can be viewed in a browser on port 8080 (chosing 8080 just because the frontend runs on 8000) with the command:
source env/bin/activate
pytest -v --cov=src/libraries/python/ --cov=src/lambda/ --cov-report=html
cd htmlcov; python -m http.server 8080
All infrastructure is managed in template.yaml
, and all changes to that template
should be deployed by committing to a CCI tracking branch.
Pharos is a hybrid serverless application, so multiple deployments of pharos-api
will create multiple independent stacks with separate serverless resources, but
the deployments will share the database server and networking resources deployed
by the pharos-database
stack. This means there is no marginal cost to deploying
additional instances of pharos-api
, because these resources are billed only
according to usage.
In general, pharos-api
consists of two api gateways, one for binary output for
map tiles, and one for JSON output, which serves all other API routes. Each API
route is served by a lambda function, with permissions to access stateful resources
(DynamoDB and S3) or the database server (deployed as
pharos-database
) as necessary.