From 9fc6e1ebcee409374558eb36f582e0d2f4389e34 Mon Sep 17 00:00:00 2001 From: Martyn Gigg Date: Tue, 19 Mar 2024 09:30:18 +0000 Subject: [PATCH 01/18] Relax "is None" to not check to simply accept false-like values Setting the slack hook to an empty string is the easiest way to disable to hook for testing. --- web/services/tasks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/services/tasks.py b/web/services/tasks.py index 55fc690..4949956 100644 --- a/web/services/tasks.py +++ b/web/services/tasks.py @@ -22,7 +22,7 @@ def send_notification_to_slack(name, :param additional_text: Any additional text provided """ slack_webhook_url = settings.SLACK_WEBHOOK_URL - if slack_webhook_url is None: + if not slack_webhook_url: return text = """Name: {} Email: {} Additional text: From 13fdec7ec514d3c72708d88419e7ae3c82cf9c88 Mon Sep 17 00:00:00 2001 From: Martyn Gigg Date: Tue, 19 Mar 2024 09:33:27 +0000 Subject: [PATCH 02/18] Overhaul run_web_tests to run with existing env/DB The old script stomped on .env files and did no cleanup. The new script uses and existing .env/DB if it exists and generates one a .env file if not. If a .env file and DB did not exist then they are cleaned at the end. Services are also only booted if they are not already running. --- bin/boot.sh | 4 +++- run_web_tests.sh | 57 ++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 56 insertions(+), 5 deletions(-) diff --git a/bin/boot.sh b/bin/boot.sh index 7f9e862..f2f8473 100755 --- a/bin/boot.sh +++ b/bin/boot.sh @@ -25,4 +25,6 @@ create_external_net # Build services docker-compose --project-name ${PROJECT_NAME} build # Bring up the stack and detach -docker-compose --project-name ${PROJECT_NAME} up -d +docker-compose --project-name ${PROJECT_NAME} up --wait + +echo "Services booted" diff --git a/run_web_tests.sh b/run_web_tests.sh index 13fa382..3c4c174 100644 --- a/run_web_tests.sh +++ b/run_web_tests.sh @@ -1,4 +1,53 @@ -cp .test_env .env -./bin/boot.sh -sleep 30 -docker exec -t errorreports_web_1 sh -c "python manage.py test" \ No newline at end of file +ENV_FILE=.env +DB_DIR=pgdata +DJANGO_SERVICE_NAME=web +CLEAN_ENV=false +CLEAN_DB=false +CLEAN_SERVICES=false + +if [[ ! -f "$ENV_FILE" ]]; then + if [[ -f "$DB_DIR/PG_VERSION" ]]; then + echo "A $ENV_FILE file could not be found yet a non-empty '${DB_DIR}' directory exists." + echo "This implies a database has been created but the credentials are missing." + echo "Tests will fail as they won't be able to access the database." + echo "IF IN A DEVELOPMENT ENVIRONMENT remove ${DB_DIR} and re-run this script." + exit 1 + fi + + echo "No $ENV_FILE file and no DB found. Generating .env file for tests." + echo "Both .env file and DB will be cleaned " + cat blank.env |\ + sed -e "s@SECRET_KEY=@SECRET_KEY=123456789abcdefghijkl@" |\ + sed -e 's@DB_USER=@DB_USER=testuser@' |\ + sed -e 's@DB_PASS=@DB_PASS=testuserpasswd@'|\ + sed -e 's@SLACK_WEBHOOK_URL=@SLACK_WEBHOOK_URL=@' > ${ENV_FILE} + CLEAN_ENV=true + CLEAN_DB=true +else + echo "Running tests using an existing environment file..." +fi + +if [[ -z $(docker-compose ps --quiet --status running $DJANGO_SERVICE_NAME) ]]; then + echo "Booting services." + ./bin/boot.sh + CLEAN_SERVICES=true +else + echo "Services already running.." +fi + +echo "Executing web tests..." +docker-compose exec $DJANGO_SERVICE_NAME sh -c "python manage.py test" + +# Clean up +if [[ $CLEAN_SERVICES == true ]]; then + echo "Shutting down services that were auto started." + ./bin/shutdown.sh +fi +if [[ $CLEAN_ENV == true ]]; then + echo "Cleaning auto-generated .env file" + rm -f $ENV_FILE +fi +if [[ $CLEAN_DB == true ]]; then + echo "Cleaning test DB" + rm -fr ${DB_DIR} +fi From d0aaab5ea186259ca84d66ccd1a6f3e4ea6d3805 Mon Sep 17 00:00:00 2001 From: Martyn Gigg Date: Tue, 19 Mar 2024 09:34:09 +0000 Subject: [PATCH 03/18] Fix target branch name for CI workflow --- .github/workflows/ci.yml | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index aa56974..b4c7256 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,10 +3,8 @@ name: CI - Ubuntu on: push: branches: - - master + - main pull_request: - branches: - - master jobs: webtests: @@ -17,10 +15,10 @@ jobs: with: python-version: 3.x architecture: x64 - - name: Checkout head + - name: Checkout head uses: actions/checkout@v2 - name: Run webtests - run: chmod +x ./run_web_tests.sh && ./run_web_tests.sh + run: bash ./run_web_tests.sh env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -32,7 +30,7 @@ jobs: with: python-version: 3.x architecture: x64 - - name: Checkout head + - name: Checkout head uses: actions/checkout@v2 - name: Install flake8 run: pip install flake8 @@ -40,4 +38,3 @@ jobs: run: cd web && flake8 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - From 2d558ac0cc1f500ad8b0512708ac273ae814d9fc Mon Sep 17 00:00:00 2001 From: Martyn Gigg Date: Tue, 19 Mar 2024 09:36:25 +0000 Subject: [PATCH 04/18] Remove old .test.env --- .test_env | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 .test_env diff --git a/.test_env b/.test_env deleted file mode 100644 index 0162fe3..0000000 --- a/.test_env +++ /dev/null @@ -1,4 +0,0 @@ -DB_NAME=TEST -DB_USER=TESTUSER -DB_PASS=password -HOST_PORT=8082 From 37f6279d99f739fc6141a657c988fd6730bd867a Mon Sep 17 00:00:00 2001 From: Martyn Gigg Date: Tue, 19 Mar 2024 09:45:04 +0000 Subject: [PATCH 05/18] Fix flake8 whitespace issues --- web/services/admin.py | 2 +- web/settings.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/web/services/admin.py b/web/services/admin.py index 4e69d70..0abd0db 100644 --- a/web/services/admin.py +++ b/web/services/admin.py @@ -1,6 +1,6 @@ from django.contrib import admin from django.urls import reverse -from django.utils.safestring import mark_safe +from django.utils.safestring import mark_safe # Register your models here. from services.models import ErrorReport, UserDetails diff --git a/web/settings.py b/web/settings.py index 3c1e9f4..ad517a8 100644 --- a/web/settings.py +++ b/web/settings.py @@ -25,7 +25,7 @@ # SECURITY WARNING: don't run with debug turned on in production! DEBUG = os.getenv('DEBUG', 'NO').lower() in ('on', 'true', 'y', 'yes') -DEFAULT_AUTO_FIELD='django.db.models.BigAutoField' +DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' ALLOWED_HOSTS = ['*'] From d0d4e63151b7ac75f5f22c6ca2aff7d84525aa49 Mon Sep 17 00:00:00 2001 From: Martyn Gigg Date: Tue, 19 Mar 2024 09:50:27 +0000 Subject: [PATCH 06/18] Accept arguments to run_web_tests Arguments are passed directly to python manage.py test command --- run_web_tests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run_web_tests.sh b/run_web_tests.sh index 3c4c174..05c52c8 100644 --- a/run_web_tests.sh +++ b/run_web_tests.sh @@ -36,7 +36,7 @@ else fi echo "Executing web tests..." -docker-compose exec $DJANGO_SERVICE_NAME sh -c "python manage.py test" +docker-compose exec $DJANGO_SERVICE_NAME sh -c "python manage.py test $@" # Clean up if [[ $CLEAN_SERVICES == true ]]; then From ec41a0f7ee1dd742814cc4c916fde751abc96996 Mon Sep 17 00:00:00 2001 From: Martyn Gigg Date: Tue, 19 Mar 2024 11:24:01 +0000 Subject: [PATCH 07/18] Replace --wait with --detach as older compose versions... don't have wait --- bin/boot.sh | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/bin/boot.sh b/bin/boot.sh index f2f8473..f90c9bb 100755 --- a/bin/boot.sh +++ b/bin/boot.sh @@ -25,6 +25,21 @@ create_external_net # Build services docker-compose --project-name ${PROJECT_NAME} build # Bring up the stack and detach -docker-compose --project-name ${PROJECT_NAME} up --wait +docker-compose --project-name ${PROJECT_NAME} up --detach -echo "Services booted" +# Replace this loop with `--wait-timeout` when it is available +# with 'docker compose' v2 +sleep_counter=0 +while [ $(docker-compose ps --quiet --filter status=running | wc -l | xargs) -ne 4 ] +do + sleep 1 + let counter++ + if [[ $counter -eq 30 ]]; then + echo "Services have not come up to a running state." + exit 1 + fi + echo "Waiting for all services to be running." +done + + +echo "Services up and running." From 45531363d5d936c45d605c260faf4a3cbaaa050a Mon Sep 17 00:00:00 2001 From: Martyn Gigg Date: Tue, 19 Mar 2024 11:33:59 +0000 Subject: [PATCH 08/18] Remove unused MAIL environment variables Set a default DEBUG value to avoid compose warning --- blank.env | 11 ++++------- docker-compose.yml | 3 --- run_web_tests.sh | 3 ++- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/blank.env b/blank.env index c129fe1..30fa9dd 100644 --- a/blank.env +++ b/blank.env @@ -1,20 +1,17 @@ -# Default config -DB_NAME=django +DEBUG=false +HOST_PORT=8083 +# Django settings. Passwords are in the password management tool +DB_NAME=django # Generate with pwgen -s 32 1 SECRET_KEY= - -# These are located in the password management tool DB_USER= DB_PASS= - DB_SERVICE=postgres DB_PORT=5432 # Can be found Slack settings SLACK_WEBHOOK_URL= - -HOST_PORT=8083 SLACK_ERROR_REPORTS_CHANNEL=#error-reports SLACK_ERROR_REPORTS_USERNAME="Error Reporter" SLACK_ERROR_REPORTS_EMOJI=:sadmantid: diff --git a/docker-compose.yml b/docker-compose.yml index 2155ffa..08dbb96 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -46,9 +46,6 @@ services: SECRET_KEY: ${SECRET_KEY} # Define this in .env for development mode. DO NOT USE IN PRODUCTION DEBUG: ${DEBUG} - MAIL_PASS: ${MAIL_PASS} - MAIL_PORT: ${MAIL_PORT} - ERROR_EMAIL: ${ERROR_EMAIL} nginx-errorreports: restart: always diff --git a/run_web_tests.sh b/run_web_tests.sh index 05c52c8..b20100e 100644 --- a/run_web_tests.sh +++ b/run_web_tests.sh @@ -17,9 +17,10 @@ if [[ ! -f "$ENV_FILE" ]]; then echo "No $ENV_FILE file and no DB found. Generating .env file for tests." echo "Both .env file and DB will be cleaned " cat blank.env |\ + sed -e "s@DEBUG=false@DEBUG=true@" |\ sed -e "s@SECRET_KEY=@SECRET_KEY=123456789abcdefghijkl@" |\ sed -e 's@DB_USER=@DB_USER=testuser@' |\ - sed -e 's@DB_PASS=@DB_PASS=testuserpasswd@'|\ + sed -e 's@DB_PASS=@DB_PASS=testuserpasswd@' |\ sed -e 's@SLACK_WEBHOOK_URL=@SLACK_WEBHOOK_URL=@' > ${ENV_FILE} CLEAN_ENV=true CLEAN_DB=true From 37f449ea0574adc222cb27053cb0c3bfd2969b2f Mon Sep 17 00:00:00 2001 From: Martyn Gigg Date: Tue, 19 Mar 2024 11:37:50 +0000 Subject: [PATCH 09/18] Use --filter=running as --status doesn't exist on older compose --- run_web_tests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run_web_tests.sh b/run_web_tests.sh index b20100e..566481d 100644 --- a/run_web_tests.sh +++ b/run_web_tests.sh @@ -28,7 +28,7 @@ else echo "Running tests using an existing environment file..." fi -if [[ -z $(docker-compose ps --quiet --status running $DJANGO_SERVICE_NAME) ]]; then +if [[ -z $(docker-compose ps --quiet --filter status=running $DJANGO_SERVICE_NAME) ]]; then echo "Booting services." ./bin/boot.sh CLEAN_SERVICES=true From 8239de30e1f34d8a330d4938e0d12a391feea082 Mon Sep 17 00:00:00 2001 From: Martyn Gigg Date: Tue, 19 Mar 2024 11:52:52 +0000 Subject: [PATCH 10/18] Update third-party GitHub action packages --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b4c7256..744f782 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,12 +11,12 @@ jobs: runs-on: ubuntu-latest steps: - name: Setup Python - uses: actions/setup-python@v1 + uses: actions/setup-python@v5 with: python-version: 3.x architecture: x64 - name: Checkout head - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Run webtests run: bash ./run_web_tests.sh env: @@ -26,12 +26,12 @@ jobs: runs-on: ubuntu-latest steps: - name: Setup Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: python-version: 3.x architecture: x64 - name: Checkout head - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Install flake8 run: pip install flake8 - name: Run flake8 From 8de7dad16f1cb53395263df22512c11dbcc95984 Mon Sep 17 00:00:00 2001 From: Martyn Gigg Date: Tue, 19 Mar 2024 12:03:40 +0000 Subject: [PATCH 11/18] Remove unused webdata directory. A volume is used for this now. --- bin/boot.sh | 1 - bin/shutdown.sh | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/bin/boot.sh b/bin/boot.sh index f90c9bb..347abdd 100755 --- a/bin/boot.sh +++ b/bin/boot.sh @@ -18,7 +18,6 @@ fi # Create empty directories, so they are not owned by root mkdir -p "$SOURCE_DIR/pgdata" -mkdir -p "$SOURCE_DIR/webdata" # Start external network create_external_net diff --git a/bin/shutdown.sh b/bin/shutdown.sh index fcb21d6..473d5ee 100755 --- a/bin/shutdown.sh +++ b/bin/shutdown.sh @@ -12,8 +12,7 @@ docker-compose down # the web data volume shouldn't really be persistent as all of the files # come from an image echo "Removing webdata volume so it is rebuilt on next startup" -rm -r "${SOURCE_DIR}/webdata" -docker volume rm errorreports_webdata +docker volume rm ${PROJECT_NAME}_webdata echo "Removing external network nginx_net" docker network rm nginx_net From 973d3bb4bf3908856ea302a2b33bf1bd7cb73ec6 Mon Sep 17 00:00:00 2001 From: Martyn Gigg Date: Tue, 19 Mar 2024 12:34:03 +0000 Subject: [PATCH 12/18] Do not clean database directory The postgres container chowns the bind mounted directory and this can then require sudo to remove on the host. Users will need to remove pgdata by hand if they want to. --- run_web_tests.sh | 6 ------ 1 file changed, 6 deletions(-) diff --git a/run_web_tests.sh b/run_web_tests.sh index 566481d..3c8fb79 100644 --- a/run_web_tests.sh +++ b/run_web_tests.sh @@ -2,7 +2,6 @@ ENV_FILE=.env DB_DIR=pgdata DJANGO_SERVICE_NAME=web CLEAN_ENV=false -CLEAN_DB=false CLEAN_SERVICES=false if [[ ! -f "$ENV_FILE" ]]; then @@ -23,7 +22,6 @@ if [[ ! -f "$ENV_FILE" ]]; then sed -e 's@DB_PASS=@DB_PASS=testuserpasswd@' |\ sed -e 's@SLACK_WEBHOOK_URL=@SLACK_WEBHOOK_URL=@' > ${ENV_FILE} CLEAN_ENV=true - CLEAN_DB=true else echo "Running tests using an existing environment file..." fi @@ -48,7 +46,3 @@ if [[ $CLEAN_ENV == true ]]; then echo "Cleaning auto-generated .env file" rm -f $ENV_FILE fi -if [[ $CLEAN_DB == true ]]; then - echo "Cleaning test DB" - rm -fr ${DB_DIR} -fi From 29ac80abf07dad1a543a08b1a0c343eebb533773 Mon Sep 17 00:00:00 2001 From: Martyn Gigg Date: Tue, 19 Mar 2024 13:39:08 +0000 Subject: [PATCH 13/18] Check for directory and not file for DB check This works in the case that we don't own the DB directory. --- run_web_tests.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/run_web_tests.sh b/run_web_tests.sh index 3c8fb79..1af8703 100644 --- a/run_web_tests.sh +++ b/run_web_tests.sh @@ -5,8 +5,8 @@ CLEAN_ENV=false CLEAN_SERVICES=false if [[ ! -f "$ENV_FILE" ]]; then - if [[ -f "$DB_DIR/PG_VERSION" ]]; then - echo "A $ENV_FILE file could not be found yet a non-empty '${DB_DIR}' directory exists." + if [[ -d ${DB_DIR} ]]; then + echo "A $ENV_FILE file could not be found yet a '${DB_DIR}' directory exists." echo "This implies a database has been created but the credentials are missing." echo "Tests will fail as they won't be able to access the database." echo "IF IN A DEVELOPMENT ENVIRONMENT remove ${DB_DIR} and re-run this script." From ecfbd19bf7d5071dc6753218a28c1037709d919d Mon Sep 17 00:00:00 2001 From: Martyn Gigg Date: Tue, 19 Mar 2024 12:58:59 +0000 Subject: [PATCH 14/18] Use a separate directory for Django's static files These are the only files that need sharing with the nginx container. This will allow is to mount the code inside container and edit in while the services are running without having to shutdown and rebuild the web image. --- docker-compose.yml | 5 +++-- nginx/sites-enabled/errorreports | 2 +- web/run_django.sh | 2 -- web/settings.py | 7 +------ 4 files changed, 5 insertions(+), 11 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 08dbb96..ddad42e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -32,7 +32,7 @@ services: restart: always build: ./web volumes: - - webdata:/usr/src/app + - webdata:/static expose: # Change the value in the nginx configuration if this is changed - "8000" @@ -54,7 +54,7 @@ services: ports: - "${HOST_PORT}:80" volumes: - - webdata:/usr/src/app + - webdata:/static networks: - default - nginx_net @@ -63,6 +63,7 @@ volumes: # This allows Nginx to serve static content, as Django won't... webdata: + networks: nginx_net: external: true diff --git a/nginx/sites-enabled/errorreports b/nginx/sites-enabled/errorreports index 7f78e1f..2693f4d 100644 --- a/nginx/sites-enabled/errorreports +++ b/nginx/sites-enabled/errorreports @@ -16,7 +16,7 @@ server { } location /static { - alias /usr/src/app/static; + root /; } location / { diff --git a/web/run_django.sh b/web/run_django.sh index 9deefe7..5d6ce30 100755 --- a/web/run_django.sh +++ b/web/run_django.sh @@ -3,8 +3,6 @@ # Collect static files into location shared by nginx echo "Running collectstatic..." python manage.py collectstatic --noinput -echo "Fixing permissions on /usr/src/app/static" -chmod 755 -R /usr/src/app/static # Create any new DB migrations and apply those in version control. # Note that running this script for the very first time produces diff --git a/web/settings.py b/web/settings.py index ad517a8..d9b4871 100644 --- a/web/settings.py +++ b/web/settings.py @@ -120,13 +120,8 @@ # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/1.8/howto/static-files/ - STATIC_URL = '/static/' -# STATICFILES_DIRS = ( -# os.path.join(BASE_DIR, 'static'), -# ) -# print(STATICFILES_DIRS) -STATIC_ROOT = os.path.join(BASE_DIR, 'static') +STATIC_ROOT = '/static' # Logging if DEBUG: From dfd01f5eb966da5d0b15cc3463146d75823ca496 Mon Sep 17 00:00:00 2001 From: Martyn Gigg Date: Tue, 19 Mar 2024 13:00:40 +0000 Subject: [PATCH 15/18] Add reload option to gunicorn in DEBUG mode. --- .gitignore | 6 ++++++ DevelopmentSetup.md | 29 +++++++++++++++++++++++++---- web/run_django.sh | 6 +++--- web/settings.py | 2 +- 4 files changed, 35 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index 3dd8f2d..98d9af7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,9 @@ +# Environment files .env + +# Shared data directories for containers pgdata/ webdata/ + +# Docker override files for local development options +docker-compose.override.yml diff --git a/DevelopmentSetup.md b/DevelopmentSetup.md index 896d64b..295bd9a 100644 --- a/DevelopmentSetup.md +++ b/DevelopmentSetup.md @@ -206,11 +206,32 @@ Not removing this data will prevent you from running the Django Admin Account st sudo rm -rf pgdata/ ``` -## Troubleshooting +## Enable live code editing + +By default changes to the Python code are not reflected in the running version until +`bin/shutdown.sh` followed by `bin/boot.sh`. This is because the Python in `web` +is copied inside the Docker image at build time. + +It is possible to configure the setup locally such that edits to the Python files +in `web` are shared with the running containers immediately. Add a file, alongside +`docker-compose.yml`, called `docker-compose.override.yml` with the following contents: + +```yml +version: '3' + +services: + web: + environment: + - DEBUG=true + volumes: + - ./web:/usr/src/app:ro + - webdata:/static +``` -If you are having problems connecting to the localhost with an obscure error code, try -add the ``DEBUG=True`` variable to your ``.env`` file. This will provide a better -error message to help you debug the problem. +This file is automatically registered by `docker-compose` and overrides the default +production configuration. **Do not add this file to the version control system!**. + +## Troubleshooting An error about invalid credentials could be caused by persisting data from a previous time you have looked at this repo. To clear any persisting data, run the shutdown script. diff --git a/web/run_django.sh b/web/run_django.sh index 5d6ce30..2eda878 100755 --- a/web/run_django.sh +++ b/web/run_django.sh @@ -18,9 +18,9 @@ python manage.py makemigrations --noinput echo "Running migrate..." python manage.py migrate --noinput -# If running in DEBUG mode add debug logging to gunicorn -if [ -n "${DEBUG}" ]; then - DEBUG_ARGS="--log-level debug --capture-output" +# If running in DEBUG mode add debug logging and hot reload to gunicorn +if [[ ${DEBUG} == true ]]; then + DEBUG_ARGS="--log-level debug --capture-output --reload" else DEBUG_ARGS= fi diff --git a/web/settings.py b/web/settings.py index d9b4871..f1085b4 100644 --- a/web/settings.py +++ b/web/settings.py @@ -23,7 +23,7 @@ SECRET_KEY = os.environ['SECRET_KEY'] # SECURITY WARNING: don't run with debug turned on in production! -DEBUG = os.getenv('DEBUG', 'NO').lower() in ('on', 'true', 'y', 'yes') +DEBUG = (os.getenv('DEBUG', 'false').lower() == 'true') DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' From be72e8fc928b61643dc590322f10d56c8b1836ff Mon Sep 17 00:00:00 2001 From: Martyn Gigg Date: Wed, 27 Mar 2024 11:22:45 +0000 Subject: [PATCH 16/18] Remove compiled stray .pyc file --- web/settings.pyc | Bin 3741 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 web/settings.pyc diff --git a/web/settings.pyc b/web/settings.pyc deleted file mode 100644 index 0a60ce0ed218b9186d862b2c9212ca9447255442..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3741 zcmeHJTX);U7T&f~hnl9`TA*Bl;T&jasZ2@<<#I|LTX9WoD@#&Z5D!|4XW}T4B{MTl z$SeF#9{3IC2b}ZG$d(N?3(g~JohTm7zTakVP37MkwR@A>-w$c_SHt@ue)8865hDt) zmWY)pDN#@&UZRsSomA$VHR6}(=aT*ps&iyPU0@gGr;r2)`&qK8n4jL zu=I#ds}yVytI-G=uM+E0@B*=KD0q?B+Z4P+F+?_ry+b=A2-InZzfA01+KJ)id&K@h z?4QKmrxDmbpdEG-e9-g?u`LR&QC!inun$4O>sJ1{O*_G>1O;)G*hj?fKq=ycuNK{4 zjRN`@&~^dc1@uV)-2?P#0qp?#49f3A^J~ODr{HyBUr=y^;BD}RS>H74Tg1Mk;O%+p zHi^TBuXIX+cZhG0_@$&H{ui+a&|W9@wFy;6`;b@@Hg@rAad=cu~KZlkY@q9H(`uBB5rSH|tXgUGF=!)%=JkKhHb9V<1FUo;wULRz_vxd+2++~8>g3L7e$#6#JbyWPmut7Be2nkGp- ziKVJ%M~kqcl)(^>Mg1&Frd<9nwgf*~G8F#@e*>i(#Sl(D6r%<4wE{jxG3vvjA;zFwDfEq{Qlx63sp$qVZMY^Guu? zy5!<49zy-SLcWM|?v^!<8B6$iB)H|}uJ#Lz{BR+-#D`-r&QhyoUVqLl#gWy*@+9Wx zOWdC=bQj4-j+Y&30!D7*p*gEdvJd`Tb{5PZs#uYec{!F{=;tL`vc0pgJuWh34U>3y zdJ+v!(RkLkd%6zJM0c2661}rhRPy0e#Oeb1&o>JRb9|>Fk+QK6ReU^2Fa@kbnBys% zcd3>4yFVjKwGNrxX6vy%Xd6ZCuIrhD(cIq;H6XWEXf+4=M-`&!_1Vb;^z*~%NZ$Hu z%!2=b{#Nq#g8eu3U7mMu)%%X?8!cv|wJ?4ZO%o;c(B$czsWfx(z;8)CRvP%0pywLK z%Y2W|9>%B^J;U(9saCIJ&te%JCOqUnV%p=}heN>cW^`hN&pU1MLasMCXE4~JQi&4Jy9?EBqY#8Ed6^8i@ zMVii>MC#bkSS(U}I?O&glm@Ts9_kN2hmZz#o1U%bw*k;yiDA>H#q0WZ=sHf``#e31 zMV7iCkm;Kd$5rJlZ>H>=3)i&u2FT4`&v|OMLp?VDpndhv8#;>I!7Fz3{;8VO;K+XncL&((d?nf4|rC!Ka)0sn_XhWxZ~zspqoc9b_pt z_FUWZ!#x*c5Hszu5pOsBrjFH9+QlA5!a=hG+YW}bQQz&`Vc=kh>a1W!hTZM^g97Mn ze>^Z@YlWie(T{LvVF&tZ*Wf~ALhwl@Kse`z#YNVdTo_Nk8fR>p@CVup z`4g6E1Wd{ Date: Wed, 27 Mar 2024 11:23:07 +0000 Subject: [PATCH 17/18] Add standard Python gitignore content --- .gitignore | 162 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 162 insertions(+) diff --git a/.gitignore b/.gitignore index 98d9af7..39c78fe 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,165 @@ webdata/ # Docker override files for local development options docker-compose.override.yml + +# Stanadard Python gitignore +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# poetry +# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control +#poetry.lock + +# pdm +# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. +#pdm.lock +# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it +# in version control. +# https://pdm.fming.dev/#use-with-ide +.pdm.toml + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +# PyCharm +# JetBrains specific template is maintained in a separate JetBrains.gitignore that can +# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# and can be added to the global gitignore or merged into this file. For a more nuclear +# option (not recommended) you can uncomment the following to ignore the entire idea folder. +#.idea/ From 2ab423d9a35518f4fdb5c7e75a6b680ea941c659 Mon Sep 17 00:00:00 2001 From: Martyn Gigg Date: Wed, 27 Mar 2024 11:24:19 +0000 Subject: [PATCH 18/18] Mount code as rw to allow migrations to be generated. --- DevelopmentSetup.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DevelopmentSetup.md b/DevelopmentSetup.md index 295bd9a..3006051 100644 --- a/DevelopmentSetup.md +++ b/DevelopmentSetup.md @@ -224,7 +224,7 @@ services: environment: - DEBUG=true volumes: - - ./web:/usr/src/app:ro + - ./web:/usr/src/app - webdata:/static ```