San Joaquin Valley Air Quality Monitoring Platform
- Platform: Python, Django
- Database: PostgreSQL with PostGIS
- Cache: Memcached
- Task Queue: Huey with Redis backend
- Containerization: Docker (via
docker compose
) - Testing: pytest, Django test framework
- Docker Desktop installed and running.
- Git and Python 3.11+ installed on your host (only needed for optional local scripts).
-
Clone the repository
git clone [email protected]:SJVAir/sjvair.com.git cd sjvair.com
-
Build and start the dev environment
docker compose --profile web up
This will spin up the following services:
- PostGIS (PostgreSQL + spatial extensions)
- Redis
- Memcached
- Django web server
- Primary task queue
-
Create a superuser
Once the containers are up:
docker compose exec web python manage.py createsuperuser
-
Build frontend assets
docker compose exec web yarn install docker compose exec web invoke build
-
Visit the app
docker compose run --rm test
Or with flags:
docker compose run --rm test pytest -s -x -k "test_something"
Install a new Python dependency:
# Add it to requirements/base.txt or requirements/develop.txt first
docker compose exec web pip install new-lib-name
Install frontend packages:
docker compose exec web yarn add new-js-lib
docker compose exec web python manage.py migrate
docker compose exec web bash
(Note: This can take up to 20 minutes or more to finish, with
import_land_use
and import_protected_areas
being the main
culprits. These can be ommitted if necessary.)
docker compose exec web bash -c "
python manage.py import_counties &&
python manage.py import_census_tracts &&
python manage.py import_cities &&
python manage.py import_school_districts &&
python manage.py import_zipcodes &&
python manage.py import_congressional_districts &&
python manage.py import_state_assembly &&
python manage.py import_state_senate &&
python manage.py import_urban_areas &&
python manage.py import_land_use &&
python manage.py import_protected_areas
"
Stop and remove all containers:
docker compose down
Start up again later:
docker compose --profile web up
-
.env
and.env.test
control environment-specific settings. -
Profiles let you selectively spin up only needed services:
# Start dev environment docker compose --profile web up # Run tests in isolation docker compose --profile test run --rm test
-
The database persists between sessions in the
pgdata
volume.