From 059cc2ac780b04b0dc867e2b3f8ade52cd4f870c Mon Sep 17 00:00:00 2001 From: DK Benjamin Date: Fri, 28 Jun 2024 11:01:08 -0400 Subject: [PATCH 1/4] Add base url referrer to Nominatum api --- backend/models/postgis/project.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/backend/models/postgis/project.py b/backend/models/postgis/project.py index 3b805ac974..0f2b847c95 100644 --- a/backend/models/postgis/project.py +++ b/backend/models/postgis/project.py @@ -61,6 +61,7 @@ ) from backend.services.grid.grid_service import GridService from backend.models.postgis.interests import Interest, project_interests +import os # Secondary table defining many-to-many join for projects that were favorited by users. project_favorites = db.Table( @@ -271,7 +272,8 @@ def set_country_info(self): "Mozilla/5.0 (Windows NT 10.0; Win64; x64) " "AppleWebKit/537.36 (KHTML, like Gecko) " "Chrome/58.0.3029.110 Safari/537.3" - ) + ), + "Referer": os.environ.get("TM_APP_BASE_URL", "https://example.com"), } try: response = requests.get(url, headers=headers) From 2219239c5f0036e4480cbc9b817e6e7ece7ba941 Mon Sep 17 00:00:00 2001 From: spwoodcock Date: Thu, 27 Jun 2024 18:29:19 +0100 Subject: [PATCH 2/4] build: update cloudformation config to use pdm export instead of venv --- scripts/aws/cloudformation/tasking-manager.template.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/aws/cloudformation/tasking-manager.template.js b/scripts/aws/cloudformation/tasking-manager.template.js index d5dc21ec30..ff42ca474c 100644 --- a/scripts/aws/cloudformation/tasking-manager.template.js +++ b/scripts/aws/cloudformation/tasking-manager.template.js @@ -437,10 +437,10 @@ const Resources = { 'cd /opt/tasking-manager/', cf.sub('git reset --hard ${GitSha}'), 'pip install --upgrade pip pdm==2.7.4', + 'pdm export --prod > requirements.txt', 'wget -6 https://s3.dualstack.us-east-1.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-py3-latest.tar.gz -O /tmp/aws-cfn-bootstrap-py3-latest.tar.gz', 'pip install /tmp/aws-cfn-bootstrap-py3-latest.tar.gz', - 'pdm install', - 'eval "$(pdm venv activate)"', + 'pip install -r requirements.txt', 'echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf', 'export LC_ALL=C', 'wget -6 https://s3.dualstack.us-east-1.amazonaws.com/amazoncloudwatch-agent/ubuntu/amd64/latest/amazon-cloudwatch-agent.deb -O /tmp/amazon-cloudwatch-agent.deb', @@ -474,7 +474,7 @@ const Resources = { cf.sub('export TM_IMAGE_UPLOAD_API_KEY="${TaskingManagerImageUploadAPIKey}"'), 'psql "host=$POSTGRES_ENDPOINT dbname=$POSTGRES_DB user=$POSTGRES_USER password=$POSTGRES_PASSWORD" -c "CREATE EXTENSION IF NOT EXISTS postgis"', cf.if('DatabaseDumpFileGiven', cf.sub('aws s3 cp ${DatabaseDump} dump.sql; sudo -u postgres psql "postgresql://$POSTGRES_USER:$POSTGRES_PASSWORD@$POSTGRES_ENDPOINT/$POSTGRES_DB" < dump.sql'), ''), - 'pdm run -vv flask db upgrade', + 'flask db upgrade', 'echo "------------------------------------------------------------"', cf.sub('export NEW_RELIC_LICENSE_KEY="${NewRelicLicense}"'), cf.sub('export TM_SENTRY_BACKEND_DSN="${SentryBackendDSN}"'), From 735f26081bd6970f987666677fdb8c1017a1ccbe Mon Sep 17 00:00:00 2001 From: spwoodcock Date: Fri, 28 Jun 2024 11:23:54 +0100 Subject: [PATCH 3/4] build: add --user flag to cloudformation pip install (avoid sys conflicts) --- scripts/aws/cloudformation/tasking-manager.template.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/aws/cloudformation/tasking-manager.template.js b/scripts/aws/cloudformation/tasking-manager.template.js index ff42ca474c..00b6552920 100644 --- a/scripts/aws/cloudformation/tasking-manager.template.js +++ b/scripts/aws/cloudformation/tasking-manager.template.js @@ -440,7 +440,7 @@ const Resources = { 'pdm export --prod > requirements.txt', 'wget -6 https://s3.dualstack.us-east-1.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-py3-latest.tar.gz -O /tmp/aws-cfn-bootstrap-py3-latest.tar.gz', 'pip install /tmp/aws-cfn-bootstrap-py3-latest.tar.gz', - 'pip install -r requirements.txt', + 'pip install --user -r requirements.txt', 'echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf', 'export LC_ALL=C', 'wget -6 https://s3.dualstack.us-east-1.amazonaws.com/amazoncloudwatch-agent/ubuntu/amd64/latest/amazon-cloudwatch-agent.deb -O /tmp/amazon-cloudwatch-agent.deb', From 1c5f01a6e807f0e86ff86744667c2b63e93e5ecf Mon Sep 17 00:00:00 2001 From: DK Benjamin Date: Fri, 28 Jun 2024 11:11:36 -0400 Subject: [PATCH 4/4] Set path to use root user local dir for python packages installed locally --- scripts/aws/cloudformation/tasking-manager.template.js | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/aws/cloudformation/tasking-manager.template.js b/scripts/aws/cloudformation/tasking-manager.template.js index 00b6552920..7a6eb5e164 100644 --- a/scripts/aws/cloudformation/tasking-manager.template.js +++ b/scripts/aws/cloudformation/tasking-manager.template.js @@ -423,6 +423,7 @@ const Resources = { 'export DEBIAN_FRONTEND=noninteractive', 'export LC_ALL="en_US.UTF-8"', 'export LC_CTYPE="en_US.UTF-8"', + 'export PATH=$PATH:/root/.local/bin', 'dpkg-reconfigure --frontend=noninteractive locales', 'sudo apt-get -q -y update', 'sudo DEBIAN_FRONTEND=noninteractive apt-get -q -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" dist-upgrade',