diff --git a/Dockerfile.dev b/Dockerfile.dev index 470627b..ba43460 100644 --- a/Dockerfile.dev +++ b/Dockerfile.dev @@ -10,6 +10,7 @@ RUN apt-get update && apt-get install -y \ binutils \ gdal-bin \ libproj-dev \ + git \ && rm -rf /var/lib/apt/lists/* COPY requirements.txt . diff --git a/README.md b/README.md index e331d4f..6c3b1b5 100644 --- a/README.md +++ b/README.md @@ -69,13 +69,13 @@ Visit it at `http://0.0.0.0:3000/` - it's important to use `0.0.0.0:3000` as tha Once you have signed in and created an account you should grant yourself super-user access so you can use every feature of the admin site. You can do that by running the following: - docker exec -it vial_web ./manage.py shell + docker exec -it vial ./manage.py shell >>> User.objects.all().update(is_superuser=True, is_staff=True) >>> to exit You'll also neet to run this command once or your static assets will 404: - docker exec -it vial_web ./manage.py collectstatic + docker exec -it vial ./manage.py collectstatic ## Importing sample data from live or staging @@ -85,7 +85,7 @@ To use these scripts, you will need two API keys: one for your development envir To import locations: ```bash -docker exec -it vial_web python /app/scripts/dev_copy_locations.py \ +docker exec -it vial python /app/scripts/dev_copy_locations.py \ --source-token '17:ce619e0...' \ --destination-token '4:09b190...' \ --source-url 'https://vial.calltheshots.us/api/searchLocations?size=100' @@ -103,7 +103,7 @@ Source locations are raw, unprocessed location data gathered by our [vaccine-fee You can import these in a similar way to locations, using this script: ```bash -docker exec -it vial_web python /app/scripts/dev_copy_source_locations.py +docker exec -it vial python /app/scripts/dev_copy_source_locations.py --source-token '17:ce619e0...' \ --destination-token '4:09b19...' \ --destination-url 'https://vial.calltheshots.us/api/searchSourceLocations?state=RI&source_name=vaccinefinder_org' @@ -114,25 +114,35 @@ This will import all of the source locations in Rhode Island that were originall Run the tests like this: - docker exec -it vial_web pytest + docker exec -it vial pytest You can pass extra arguments to run specific tests - for example: -- `docker exec -it vial_web pytest -k test_admin_location_actions_for_queue` - run specific test -- `docker exec -it vial_web pytest api/test_export_mapbox.py` - run the tests in the `vaccinate/api/test_export_mapbox.py` module -- `docker exec -it vial_web pytest --lf` - run tests that failed during the last test run +- `docker exec -it vial pytest -k test_admin_location_actions_for_queue` - run specific test +- `docker exec -it vial pytest api/test_export_mapbox.py` - run the tests in the `vaccinate/api/test_export_mapbox.py` module +- `docker exec -it vial pytest --lf` - run tests that failed during the last test run ## Code formatting and linting This repository uses [Black](https://github.com/psf/black) and [isort](https://pycqa.github.io/isort/) to enforce coding style as part of the CI tests. -Run `black .` and `isort .` in the top-level directory to ensure your code is formatted correctly, then enjoy never having to think about how to best indent your Python code ever again. +Run `docker exec -it vial black .` and `docker exec -it vial isort .` to ensure your code is formatted correctly, then enjoy never having to think about how to best indent your Python code ever again. -Run `scripts/run-flake8` in the top-level directory to check for missing or unused imports. +Run `docker exec -it vial /app/scripts/run-flake8` to check for missing or unused imports. -Run `scripts/run-mypy` in the top-level directory to run the mypy type checker. +Run `docker exec -it vial /app/scripts/run-mypy` run the mypy type checker. -Run `scripts/lint-migrations` in the top-level directory to verify that migrations do not have any backwards-incompatible changes that could cause problems during a deploy while the site is serving traffic. +Run `docker exec -it vial /app/scripts/lint-migrations` to verify that migrations do not have any backwards-incompatible changes that could cause problems during a deploy while the site is serving traffic. + +## Rebuilding the containers + +Any time you need to apply changes to `requirements.txt` or `Dockerfile.dev` you should stop the conatiners and run this: + + docker-compose build + +Then start the environment again with: + + docker-compose up ## Logging SQL diff --git a/docker-compose.yml b/docker-compose.yml index 5c4eb65..6ac413d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -13,7 +13,7 @@ services: POSTGRES_DB: vaccinate POSTGRES_PASSWORD: postgres web: - container_name: vial_web + container_name: vial build: context: . dockerfile: Dockerfile.dev diff --git a/scripts/lint-migrations b/scripts/lint-migrations index 1ec2aed..1473d09 100755 --- a/scripts/lint-migrations +++ b/scripts/lint-migrations @@ -1,5 +1,5 @@ #!/bin/bash -./vaccinate/manage.py lintmigrations \ +/app/vaccinate/manage.py lintmigrations \ 7aefb8cb6c19968ba7b97fdd099ccdd224e756f1 \ --project-root-path ./vaccinate \ --ignore-name \ diff --git a/scripts/run-flake8 b/scripts/run-flake8 index 5c742ed..2390e89 100755 --- a/scripts/run-flake8 +++ b/scripts/run-flake8 @@ -1,2 +1,2 @@ #!/bin/bash -(cd vaccinate && flake8) +(cd /app/vaccinate && flake8) diff --git a/scripts/run-mypy b/scripts/run-mypy index f048f78..f194c86 100755 --- a/scripts/run-mypy +++ b/scripts/run-mypy @@ -1,3 +1,3 @@ #!/bin/bash -(cd vaccinate && mypy .) +(cd /app/vaccinate && mypy .)