Skip to content

Commit 3cbbb11

Browse files
authored
Merge pull request #1474 from ImagingDataCommons/idc-prod-sp
Release 46 / v21
2 parents 2d3c3c5 + 18d9408 commit 3cbbb11

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+764
-922
lines changed

.circleci/config.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ jobs:
119119
TZ: "/usr/share/zoneinfo/America/Los_Angeles"
120120
working_directory: ~/IDC-WebApp
121121
docker:
122-
- image: cimg/python:3.9.2
122+
- image: cimg/python:3.11
123123
- image: cimg/mysql:8.0
124124
environment:
125125
MYSQL_ROOT_HOST: "%"
@@ -195,7 +195,7 @@ jobs:
195195
TZ: "/usr/share/zoneinfo/America/Los_Angeles"
196196
working_directory: ~/IDC-WebApp
197197
docker:
198-
- image: cimg/python:3.9.2
198+
- image: cimg/python:3.11
199199
steps:
200200
- restore_cache:
201201
keys:
@@ -209,7 +209,7 @@ jobs:
209209
sudo -E rm -rf ./lib
210210
sudo -E /bin/bash ./shell/unpack_for_deployment.sh
211211
sudo -E gcloud config set app/cloud_build_timeout 1600
212-
sudo -E gcloud app deploy --verbosity=debug ./app.yaml --quiet
212+
sudo -E gcloud app deploy --verbosity=debug ./app.yaml --service-account=${WEBAPP_RUNTIME_SA_NAME} --quiet
213213
workflows:
214214
version: 2
215215
build_and_deploy:

Dockerfile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
###
22
#
3-
# Copyright 2017, Institute for Systems Biology
3+
# Copyright 2025, Institute for Systems Biology
44
#
55
# Licensed under the Apache License, Version 2.0 (the "License");
66
# you may not use this file except in compliance with the License.
@@ -18,7 +18,7 @@
1818

1919
# Dockerfile extending the Python Community image from Dockerhub with application files for a
2020
# single application.
21-
FROM python:3.9-bullseye
21+
FROM python:3.11-bookworm
2222

2323
SHELL ["/bin/bash", "-c"]
2424

@@ -29,12 +29,12 @@ RUN apt-get update
2929
RUN apt-get install -y wget
3030
# TODO: we need to start using the keyring instead
3131
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv A8D3785C
32-
RUN wget "http://repo.mysql.com/mysql-apt-config_0.8.29-1_all.deb" -P /tmp
32+
RUN wget "http://repo.mysql.com/mysql-apt-config_0.8.30-1_all.deb" -P /tmp
3333

3434
# install lsb-release (a dependency of mysql-apt-config), since dpkg doesn't
3535
# do dependency resolution
3636
RUN apt-get install -y lsb-release
37-
RUN dpkg --install /tmp/mysql-apt-config_0.8.29-1_all.deb
37+
RUN dpkg --install /tmp/mysql-apt-config_0.8.30-1_all.deb
3838

3939
# fetch the updated package metadata (in particular, mysql-server)
4040
RUN apt-get update
@@ -44,10 +44,10 @@ RUN apt-get install -y mysql-server
4444

4545
RUN apt-get -y install build-essential
4646
RUN apt-get -y install --reinstall python3-m2crypto python3-cryptography
47-
RUN apt-get -y install libxml2-dev libxmlsec1-dev swig
47+
RUN apt-get -y install libxml2-dev libxmlsec1-dev swig pkg-config
4848
RUN pip install pexpect
4949

50-
RUN apt-get -y install unzip libffi-dev libssl-dev libmysqlclient-dev python3-mysqldb python3-dev libpython3-dev git ruby g++ curl
50+
RUN apt-get -y install unzip libffi-dev libssl-dev libmysqlclient-dev python3-mysqldb python3-dev libpython3-dev git g++ curl
5151

5252
ADD . /app
5353

README.md

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,16 @@ You will need to set the `shell/python-su.sh` file to be executable. You can do
5555
To run your server in PyCharm:
5656

5757
1. Make sure your Vagrant machine is running by going to **Tools > Vagrant > Up**
58-
- If this is the first time you've built the VM, it can be time consuming.
59-
- Our VMs are currently running Ubuntu 16.0.4 LTS, which is what the app deploys under as well.
60-
2. Once the VM has built, click on the Run or Debug icons in the toolbar (upper-right corner of the PyCharm GUI)
61-
- Your server will start and the PyCharm console should show all the logs and output from the system.
62-
- If you are running in debug, you can also use breakpoints to stop the execution and examine variables and code as it runs.
58+
* If this is the first time you've built the VM, it can be time consuming.
59+
* Our VMs are currently running Debian 12 (Bookworm) LTS, which is what the app deploys under as well.
60+
2. Once the VM is built, you will need to update the kernel headers and Guest Additions
61+
* Kernel header update: `sudo apt-get -y install dkms build-essential linux-headers-$(uname -r)`
62+
* NOTE: you may get a 'package not found' error here; if so, you'll need to look up the current header package for this install and use that instead.
63+
* Guest Additions ISO mounting and installation: https://docs.bitnami.com/virtual-machine/faq/configuration/install-virtualbox-guest-additions/
64+
3. Next, set the `shell/python-su.sh` script to executable in the vagrant machine's command line with the command `chmod +x /home/vagrant/www/shell/python-su.sh`
65+
4. You can now click on the Run or Debug icons in the toolbar (upper-right corner of the PyCharm GUI)
66+
* Your server will start and the PyCharm console should show all the logs and output from the system.
67+
* If you are running in debug, you can also use breakpoints to stop the execution and examine variables and code as it runs.
6368

6469
## Adding Python Dependencies
6570

@@ -71,11 +76,11 @@ To update your existing python dependencies because of a change, or to pull down
7176

7277
1. Click **Tools > Start SSH session...**
7378
2. Select the Vagrant VM Connection you set up
74-
3. Type `cd www; sudo pip3 install -r requirements.txt --upgrade -t lib/`
79+
3. Type `cd www; sudo pip install -r requirements.txt --upgrade -t lib/`
7580

7681
Or from the command line, you can do this by doing the following:
7782

7883
1. Open a terminal in the project directory
7984
2. Type `vagrant ssh` to login to the virtual machine
8085
3. Change directory to the `www` directory (`/home/vagrant/www/` is the full path)
81-
4. Run `pip3 install -r requirements.txt --upgrade -t lib/`
86+
4. Run `pip install -r requirements.txt --upgrade -t lib/`

Vagrantfile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ Vagrant.configure(2) do |config|
1717
vb.customize ["modifyvm", :id, "--paravirtprovider", "default"]
1818
end
1919

20-
config.vm.box_version = "11.20241217.1"
21-
config.vm.box = "debian/bullseye64"
20+
config.vm.box = "debian/bookworm64"
21+
config.vm.box_version = "12.20250126.1"
2222

2323
# WebApp ports
2424
config.vm.network "forwarded_port", guest: 8086, host: 8086
@@ -38,10 +38,11 @@ Vagrant.configure(2) do |config|
3838
config.vm.provision :shell, inline: "sudo apt-get install dos2unix", :run => 'always'
3939
config.vm.provision :shell, inline: "dos2unix /home/vagrant/www/shell/*.sh", :run => 'always'
4040
config.vm.provision :shell, inline: "echo 'source /home/vagrant/www/shell/env.sh' > /etc/profile.d/sa-environment.sh", :run => 'always'
41+
# This script will kill any further building if settings appear to be wrong
42+
config.vm.provision "shell", path: 'shell/check-settings.sh', :run => 'always'
4143
config.vm.provision "shell", path: 'shell/install-deps.sh'
4244
# TODO: Adjust create and setup to check for database and run if it's not found so they can be set to always
4345
config.vm.provision "shell", path: 'shell/create-database.sh'
4446
config.vm.provision "shell", path: 'shell/database-setup.sh'
45-
config.vm.provision "shell", path: 'shell/vagrant-start-server.sh', :run => 'always'
4647
config.vm.provision "shell", path: 'shell/vagrant-set-env.sh', :run => 'always'
4748
end

etl/etl.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
from django.contrib.auth.models import User
4949
idc_superuser = User.objects.get(username="idc")
5050

51-
logger = logging.getLogger('main_logger')
51+
logger = logging.getLogger(__name__)
5252

5353
ATTR_SET = {}
5454
DISPLAY_VALS = {}

idc/demo_views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
from django.utils.html import escape
4343

4444
debug = settings.DEBUG
45-
logger = logging.getLogger('main_logger')
45+
logger = logging.getLogger(__name__)
4646

4747
BQ_ATTEMPT_MAX = 10
4848
WEBAPP_LOGIN_LOG_NAME = settings.WEBAPP_LOGIN_LOG_NAME

idc/domain_redirect_middleware.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from django.http import HttpResponsePermanentRedirect
2020
from django.conf import settings
2121

22-
logger = logging.getLogger('main_logger')
22+
logger = logging.getLogger(__name__)
2323

2424

2525
class DomainRedirectMiddleware(object):

idc/metadata_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from idc_collections.models import Attribute
1919
from django.conf import settings
2020

21-
logger = logging.getLogger('main_logger')
21+
logger = logging.getLogger(__name__)
2222

2323

2424
def retTuple(x, order_docs):

idc/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
import logging
2121

22-
logger = logging.getLogger('main_logger')
22+
logger = logging.getLogger(__name__)
2323

2424

2525
class AppInfo(models.Model):

idc/settings.py

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
###
2-
# Copyright 2015-2023, Institute for Systems Biology
2+
# Copyright 2015-2025, Institute for Systems Biology
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
55
# you may not use this file except in compliance with the License.
@@ -84,13 +84,14 @@
8484
DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'
8585

8686
GCLOUD_PROJECT_ID = os.environ.get('GCLOUD_PROJECT_ID', '')
87+
GCLOUD_TOPICS_ID = os.environ.get('GCLOUD_TOPICS_ID', GCLOUD_PROJECT_ID)
8788
GCLOUD_PROJECT_NUMBER = os.environ.get('GCLOUD_PROJECT_NUMBER', '')
8889
BIGQUERY_PROJECT_ID = os.environ.get('BIGQUERY_PROJECT_ID', GCLOUD_PROJECT_ID)
8990
BIGQUERY_DATA_PROJECT_ID = os.environ.get('BIGQUERY_DATA_PROJECT_ID', GCLOUD_PROJECT_ID)
9091
BIGQUERY_USER_DATA_PROJECT_ID = os.environ.get('BIGQUERY_USER_DATA_PROJECT_ID', GCLOUD_PROJECT_ID)
9192
BIGQUERY_USER_MANIFEST_DATASET = os.environ.get('BIGQUERY_USER_MANIFEST_DATASET', 'dev_user_dataset')
9293
BIGQUERY_USER_MANIFEST_TIMEOUT = int(os.environ.get('BIGQUERY_USER_MANIFEST_TIMEOUT', '7'))
93-
PUBSUB_USER_MANIFEST_TOPIC = "projects/{}/topics/{}".format(GCLOUD_PROJECT_ID, os.environ.get('PUBSUB_USER_MANIFEST_TOPIC', 'user-manifest'))
94+
PUBSUB_USER_MANIFEST_TOPIC = "projects/{}/topics/{}".format(GCLOUD_TOPICS_ID, os.environ.get('PUBSUB_USER_MANIFEST_TOPIC', 'user-manifest'))
9495
USER_MANIFESTS_FOLDER = os.environ.get('USER_MANIFESTS_FOLDER', 'user-manifests')
9596
RESULT_BUCKET = os.environ.get('RESULT_BUCKET', 'idc-dev-files')
9697

@@ -284,9 +285,10 @@
284285
'django.contrib.sessions.middleware.SessionMiddleware',
285286
'idc.checkreqsize_middleware.CheckReqSize',
286287
'django.middleware.csrf.CsrfViewMiddleware',
288+
'django.contrib.messages.middleware.MessageMiddleware',
287289
'django.contrib.auth.middleware.AuthenticationMiddleware',
288290
'adminrestrict.middleware.AdminPagesRestrictMiddleware',
289-
'django.contrib.messages.middleware.MessageMiddleware',
291+
"allauth.account.middleware.AccountMiddleware",
290292
'idc.team_only_middleware.TeamOnly',
291293
# Uncomment the next line for simple clickjacking protection:
292294
'django.middleware.clickjacking.XFrameOptionsMiddleware',
@@ -311,7 +313,6 @@
311313
'django.contrib.humanize',
312314
'anymail',
313315
'idc',
314-
'data_upload',
315316
'sharing',
316317
'cohorts',
317318
'idc_collections',
@@ -590,19 +591,28 @@
590591
DEFAULT_FROM_EMAIL = NOTIFICATION_EMAIL_FROM_ADDRESS
591592
SERVER_EMAIL = "[email protected]"
592593

593-
GOOGLE_APPLICATION_CREDENTIALS = join(dirname(__file__), '../{}{}'.format(SECURE_LOCAL_PATH,os.environ.get('GOOGLE_APPLICATION_CREDENTIALS', '')))
594594
OAUTH2_CLIENT_ID = os.environ.get('OAUTH2_CLIENT_ID', '')
595595
OAUTH2_CLIENT_SECRET = os.environ.get('OAUTH2_CLIENT_SECRET', '')
596596

597-
if not exists(GOOGLE_APPLICATION_CREDENTIALS):
598-
print("[ERROR] Google application credentials file wasn't found! Provided path: {}".format(GOOGLE_APPLICATION_CREDENTIALS))
599-
exit(1)
597+
# WJRL 5/21/25: Pulling in the GAC test code now in use on ISB-CGC to support keyless deployment:
598+
#
599+
# Deployed systems retrieve credentials from the metadata server, but a local VM build must provide a credentials file
600+
# for some actions. CircleCI needs SA access but can make use of the deployment SA's key.
601+
GOOGLE_APPLICATION_CREDENTIALS = None
602+
603+
if IS_DEV:
604+
GOOGLE_APPLICATION_CREDENTIALS = os.environ.get('GOOGLE_APPLICATION_CREDENTIALS', '')
605+
elif IS_CI:
606+
GOOGLE_APPLICATION_CREDENTIALS = "deployment.key.json"
607+
608+
if not IS_APP_ENGINE:
609+
if GOOGLE_APPLICATION_CREDENTIALS is not None and not exists(GOOGLE_APPLICATION_CREDENTIALS):
610+
print("[ERROR] Google application credentials file wasn't found! Provided path: {}".format(GOOGLE_APPLICATION_CREDENTIALS))
611+
exit(1)
612+
print("[STATUS] GOOGLE_APPLICATION_CREDENTIALS: {}".format(GOOGLE_APPLICATION_CREDENTIALS))
613+
else:
614+
print("[STATUS] AppEngine Flex detected--default credentials will be used.")
600615

601-
#################################
602-
# For NIH/eRA Commons login #
603-
#################################
604-
GOOGLE_GROUP_ADMIN = os.environ.get('GOOGLE_GROUP_ADMIN', '')
605-
SUPERADMIN_FOR_REPORTS = os.environ.get('SUPERADMIN_FOR_REPORTS', '')
606616

607617

608618
##############################
@@ -668,7 +678,7 @@
668678

669679

670680
# Explicitly check for known problems in descriptions and names provided by users
671-
DENYLIST_RE = r'((?i)<script>|(?i)</script>|!\[\]|!!\[\]|\[\]\[\".*\"\]|(?i)<iframe>|(?i)</iframe>)'
681+
DENYLIST_RE = r'(<script>|</script>|!\[\]|!!\[\]|\[\]\[\".*\"\]|<iframe>|</iframe>)'
672682
ATTRIBUTE_DISALLOW_RE = r'([^a-zA-Z0-9_])'
673683

674684
if DEBUG and DEBUG_TOOLBAR and not IS_APP_ENGINE:

0 commit comments

Comments
 (0)