The Baytree App is designed to facilitate the tracking of each volunteers' progress with each client.
-
Install Docker
-
Create a file named
.env
(for environment variables) in the same directory asdocker-compose.yml
. It should look like this:SECRET_KEY=something_random MYSQL_USER=dbuser MYSQL_PASSWORD=something_random EMAIL_HOST=smtp.gmail.com EMAIL_PORT=587 [email protected] EMAIL_PASSWORD=the_password MOCK_MYSQL_DATABASE=views_mock_db VIEWS_USERNAME=the_username VIEWS_PASSWORD=the_password CELERY_BROKER_URL=redis://redis:6379 CELERY_RESULT_BACKEND=redis://redis:6379 AWS_ACCESS_KEY_ID= {your_id} AWS_SECRET_ACCESS_KEY= {your_key} AWS_DEFAULT_REGION= us-east-1 GRAFANA_LOGGING_URL=logs-prod3.grafana.net GRAFANA_USER=319402 GRAFANA_API_KEY={your_Grafana_API_key} VIEWS_BASE_URL=base_url_for_views_apis LOGGER_TEST_ENV=gitlab ENVIRONMENT=dev
Please set the LOGGER_TEST_ENV var to your desired testing environment which could be 'local' for running the fluent logger tests locally or create a GitLab CI/CD variable named
LOGGER_TEST_ENV
and set it togitlab
to run the tests in a GitLab CI-CD environment.Please set the ENVIRONMENT variable based on your desired environment which may either 'dev','staging', or 'production'.
According to Google's new less-secure app policy, the gmail account must have 2-factor authentication enabled and an "app password" must be created which can be used with Django.
Replace instances of
something_random
with random strings, andthe_username
andthe_password
with appropriate credentials (which you can obtain by talking to someone on the team).You can get the
your_Grafana_API_key
by talking to someone on the team.You can get the
your_id
andyour_key
by talking to someone on the team. ForVIEWS_BASE_URL
, set tohttps://app.viewsapp.net/api/restful/
to call the actual Views APIs orhttp://views-mock:5001/
to call the mock Views APIs. -
Install frontend dependencies (if running in Docker - see frontend section if not):
docker compose run --rm frontend npm install docker compose run --rm admin-frontend npm install
-
You need to build the docker compose first or when you updated the dependencies
docker compose build
-
Then, run the application:
docker compose up
-
Run migrations and create a superuser (while the application is running):
docker exec baytree_server python manage.py migrate docker exec views-mock python manage.py migrate docker exec -it baytree_server python manage.py createsuperuser
-
install default preference:
docker exec baytree_server python manage.py loaddata defaultPreferences.json docker exec baytree_server python manage.py loaddata goalCategories docker exec baytree_server python manage.py loaddata ukHolidays
-
You can use
Ctrl+C
to stop running the application
-
To run the entire application:
docker compose up
-
To run only the backend + database:
docker compose up server
-
If new backend packages have been installed, run
docker compose build
prior to running theup
commands above -
If new frontend packages have been installed, run the following prior to running the
up
commands above:docker compose run --rm frontend npm install docker compose run --rm admin-frontend npm install
If you want to open a terminal within a container, use the command:
docker exec -it [container-name] bash
The recommended way to run the backend is within Docker (using the instructions above).
After a model change, run the following to make database migrations:
docker exec <baytree_server/views-mock> python manage.py makemigrations
To migrate your database, either because you or someone else made database migrations, run:
docker exec <baytree_server/views-mock> python manage.py migrate
To install default preference:
docker exec baytree_server python manage.py loaddata defaultPreferences.json
docker exec baytree_server python manage.py loaddata goalCategories
docker exec baytree_server python manage.py loaddata ukHolidays
You can create a super (admin) user by running:
docker exec -it baytree_server python manage.py createsuperuser
The project uses Celery to run background tasks. To start up Celery use the following command:
docker exec baytree_server python manage.py start_celery
To stop the Celery worker, you should use the following command:
docker exec baytree_server python manage.py stop_celery
docker exec -it views-mock python manage.py createdb
You can install a new package by adding it to requirements.txt
and then running docker compose build
while the application isn't running.
Run these commands to manage the depenedencies for containers baytree_frontend
and baytree_admin_frontend
-
Install packages as build dependenency, with the application running:
docker exec [container_name] npm install [package_1] [package_2] ... # Shorthand syntax docker exec [container_name] npm i [package_1] [package_2] ...
-
Install packages as a develeper dependency, run the commands above with
--save-dev
tag:docker exec [container_name] npm install --save-dev [package_1] [package_2] ... # Shorthand syntax docker exec [container_name] npm i -D [package_1] [package_2] ...
-
Unistall a package, with the application running
docker exec [container_name] npm uninstall [package_1] [package_2] ...
The frontends can either be run in Docker (using the instructions above) or outside of Docker. Due to the large number of files in node_modules
, file system performance may be better outside of Docker. To run outside of Docker:
- Install Node.js
- Run
npm install
in both frontend folders - Use the command
docker compose up server
to run only the backend + database - Use the command
docker compose up views-mock
to run the node server for mocking Views APIs. - Use the following commands to run the frontends:
- frontend:
npm start
- admin-frontend:
npm run dev
- frontend:
Navigate to http://localhost:3001/admin in your browser and use your superuser credentials (or any admin user credentials) to log in
For information on deployment, see README.md
in scripts/
folder.