diff --git a/Makefile b/Makefile index 13f33cf71..216c7a80c 100644 --- a/Makefile +++ b/Makefile @@ -82,7 +82,7 @@ release-version: .env $(ENVREPLACE) TEST_BASIC_AUTH_PASSWORD $$(openssl rand -base64 42) .env .PHONY: docker-compose.yml -docker-compose.yml: base.yml dev.yml staging.yml prod.yml config.mk $(PGPASS_PATH) release-version +docker-compose.yml: base.yml dev.yml staging.yml prod.yml config.mk $(PGPASS_PATH) release-version .env case "$(DEPLOY_ENVIRONMENT)" in \ dev|staging) docker compose -f base.yml -f $(DEPLOY_ENVIRONMENT).yml config > docker-compose.yml;; \ prod) docker compose -f base.yml -f staging.yml -f $(DEPLOY_ENVIRONMENT).yml config > docker-compose.yml;; \ @@ -100,7 +100,7 @@ secrets: $(SECRETS_DIR) $(GENERATED_SECRETS) done .PHONY: deploy -deploy: build .env +deploy: build docker compose pull db redis elasticsearch ifneq ($(DEPLOY_ENVIRONMENT),dev) docker compose pull nginx diff --git a/deploy/conf/.env.template b/deploy/conf/.env.template index 6686529fc..ce64ac44e 100644 --- a/deploy/conf/.env.template +++ b/deploy/conf/.env.template @@ -1,8 +1,9 @@ # Docker build # UBUNTU_MIRROR=mirror.arizona.edu +VIRTUAL_ENV=/home/comses/virtualenvs/comses.venv UBUNTU_MIRROR=archive.ubuntu.com # set PATH defaults for cron execution -PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin +PATH="${VIRTUAL_ENV}/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" # app settings RELEASE_VERSION= @@ -21,7 +22,7 @@ DISCOURSE_BASE_URL= DISCOURSE_API_USERNAME= # elastic search -ES_VERSION=7.17.22 +ES_VERSION=7.17.26 # email EMAIL_SUBJECT_PREFIX="[CoMSES Net]" diff --git a/django/Dockerfile b/django/Dockerfile index 8279660f3..c78ac5ec5 100644 --- a/django/Dockerfile +++ b/django/Dockerfile @@ -1,8 +1,10 @@ -FROM comses/base:jammy +FROM comses/base:noble ARG REQUIREMENTS_FILE=requirements-dev.txt ARG RUN_SCRIPT=./deploy/dev.sh ARG UBUNTU_MIRROR=archive.ubuntu.com +ENV VIRTUAL_ENV=/home/comses/virtualenvs/comses.venv +ENV PATH="${VIRTUAL_ENV}/bin:$PATH" RUN rm -f /etc/apt/apt.conf.d/docker-clean; echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache RUN --mount=type=cache,target=/var/lib/apt,sharing=locked \ @@ -39,6 +41,7 @@ RUN --mount=type=cache,target=/var/lib/apt,sharing=locked \ unrar-free \ unzip \ && update-alternatives --install /usr/bin/python python /usr/bin/python3 1000 \ + && python -m venv ${VIRTUAL_ENV} \ && apt-get upgrade -q -y -o Dpkg::Options::="--force-confold" \ && mkdir -p /etc/service/django \ && touch /etc/service/django/run /etc/postgresql-backup-pre \ diff --git a/django/core/tests/test_views.py b/django/core/tests/test_views.py index b9c5c5b80..e8f31fd6e 100644 --- a/django/core/tests/test_views.py +++ b/django/core/tests/test_views.py @@ -197,7 +197,7 @@ def test_mark_spam(self): ) event.refresh_from_db() # non-moderators cannot mark content as spam - self.assertEquals(response.status_code, 403) + self.assertEqual(response.status_code, 403) self.assertFalse(event.is_marked_spam) # check moderator self.client.login( diff --git a/django/home/tests/test_metrics.py b/django/home/tests/test_metrics.py index 75d7297a3..f3f846786 100644 --- a/django/home/tests/test_metrics.py +++ b/django/home/tests/test_metrics.py @@ -39,13 +39,13 @@ def test_convert_timeseries(self): ) for chart_data in highcharts_timeseries: # 2012 and 2013 should also be 0 - self.assertEquals( + self.assertEqual( tuple(chart_data["data"][0:2]), (0, 0), "2012-13 should be zeroed out", ) # missing year 2016 - self.assertEquals( + self.assertEqual( chart_data["data"][4], 0, f"5th entry (2016) should be 0 {chart_data['name']}", @@ -53,4 +53,4 @@ def test_convert_timeseries(self): self.assertTrue( chart_data["name"] in OS_NAMES, f"Invalid OS name {chart_data['name']}" ) - self.assertEquals(len(chart_data["data"]), 7, "Should be 7 years of data") + self.assertEqual(len(chart_data["data"]), 7, "Should be 7 years of data") diff --git a/django/library/tests/test_datacite_api.py b/django/library/tests/test_datacite_api.py index c1b2a42da..3893bf4f0 100644 --- a/django/library/tests/test_datacite_api.py +++ b/django/library/tests/test_datacite_api.py @@ -50,7 +50,7 @@ def test_mint_new_doi_for_release(self): self.assertTrue(self.api.is_datacite_available()) release = self.codebase.releases.first() log, ok = self.api.mint_public_doi(release) - self.assertEquals(log.http_status, 200, "should have successfully minted a DOI") + self.assertEqual(log.http_status, 200, "should have successfully minted a DOI") self.assertTrue(self.api.doi_matches_pattern(doi)) def test_update_metadata_for_release(self): diff --git a/django/library/tests/test_fs.py b/django/library/tests/test_fs.py index 580ee5d6b..5bcd21f9a 100644 --- a/django/library/tests/test_fs.py +++ b/django/library/tests/test_fs.py @@ -43,8 +43,8 @@ def test_zipfile_saving(self): fs_api=fs_api, ) logs, level = msgs.serialize() - self.assertEquals(level, MessageLevels.warning) - self.assertEquals(len(logs), 2) + self.assertEqual(level, MessageLevels.warning) + self.assertEqual(len(logs), 2) self.assertEqual( set( fs_api.list(StagingDirectories.originals, FileCategoryDirectories.code) @@ -77,8 +77,8 @@ def test_invalid_zipfile_saving(self): FileCategoryDirectories.code, content=f, name="invalid.zip" ) logs, level = msgs.serialize() - self.assertEquals(level, MessageLevels.error) - self.assertEquals(len(logs), 1) + self.assertEqual(level, MessageLevels.error) + self.assertEqual(len(logs), 1) @classmethod def tearDownClass(cls): diff --git a/django/library/tests/test_models.py b/django/library/tests/test_models.py index da11f1e85..02a2f72fe 100644 --- a/django/library/tests/test_models.py +++ b/django/library/tests/test_models.py @@ -30,11 +30,11 @@ def setUp(self): ) def test_base_dir(self): - self.assertEquals( + self.assertEqual( self.c1.base_library_dir, pathlib.Path(settings.LIBRARY_ROOT, str(self.c1.uuid)), ) - self.assertEquals( + self.assertEqual( self.c1.base_git_dir, pathlib.Path(settings.REPOSITORY_ROOT, str(self.c1.uuid)), ) @@ -43,8 +43,8 @@ def test_create_release(self): release = ReleaseSetup.setUpPublishableDraftRelease(self.c1) release.validate_publishable() release.publish() - self.assertEquals(self.c1.latest_version, release) - self.assertEquals( + self.assertEqual(self.c1.latest_version, release) + self.assertEqual( CodebaseRelease.objects.get( codebase=self.c1, version_number=release.version_number ), diff --git a/django/requirements.txt b/django/requirements.txt index ea4d3debc..72079500d 100644 --- a/django/requirements.txt +++ b/django/requirements.txt @@ -30,6 +30,7 @@ elasticsearch>=7.0.0,<8.0.0 html2text>=2016.9.19 jinja2==3.1.4 jsonschema==4.23.0 +jwt==1.3.1 # needed for allauth markdown==3.7 nltk>=3.8.1,<4.0.0 numpy==1.26.4