The DesignSafe-CI Portal can be run using Docker and Docker Compose. You will need both Docker and Docker Compose pre-installed on the system you wish to run the portal on.
If you are on a Mac or a Windows machine, the recommended method is to install Docker Desktop, which will install both Docker and Docker Compose, which is required to run Docker on Mac/Windows hosts.
-
Clone the repo
$ git clone https://github.com/DesignSafe-CI/portal.git $ cd portal -
Configure environment variables
Make a copy of designsafe.sample.env and rename it to
designsafe.env. Configure variables as necessary. See designsafe.sample.env for details of configuration.Required variables:
DJANGO_DEBUG: should be set toTruefor developmentDJANGO_SECRET_KEY: should be changed for productionTAS_*: should be set to enable direct access todjango.contrib.adminTAPIS_*: should be set to enable Tapis API integration (authentication, etc.)RT_*: should be set to enable ticketing
Make a copy of rabbitmq.sample.env then rename it to
rabbitmq.env. -
Configure ngrok
a. Install ngrok, and create an ngrok account.
b. Copy conf/env_files/ngrok.sample.env to
conf/env_files/ngrok.env.c. In
conf/env_files/ngrok.env, set theNGROK_AUTHTOKENandNGROK_DOMAINvariables using your authtoken and static ngrok domain found in your ngrok dashboard. -
Build the containers and frontend packages
-
Containers:
make build-dev
or
docker-compose -f conf/docker/docker-compose-dev.yml build
-
Angular Frontend + static assets:
npm ci docker run -v `pwd`:`pwd` -w `pwd` -it node:16 /bin/bash -c "npm run build"
Note: If you are working with the frontend code and want it to automatically update, use
npm run devrather thannpm run buildto have it build upon saving the file. -
React Frontend (in another terminal):
cd client npm ci npm run start
-
-
Start local containers
$ make startor
$ docker-compose -f ./conf/docker/docker-compose-dev.all.debug.yml upthen, in a new tab
$ docker exec -it des_django bash $ ./manage.py migrate $ ./manage.py collectstatic --ignore demo --no-input $ ./manage.py createsuperuser $ ./manage.py es_setup # optional: see https://tacc-main.atlassian.net/wiki/spaces/UP/pages/6659524#es_setup for more info -
Setup local access to the portal:
Add a record to your local hosts file for
127.0.0.1 designsafe.dev$ sudo vim /etc/hosts -
Login to the Portal in your browser at designsafe.dev/login.
To login to the CMS admin, set your user as staff or superuser. To access the workspace quickly, bypass the profile edit form.
Every file needed is in conf/nginx/certs.
- Open mac's Keychain Access
- File > Import Items
- Navigate to
$PROJECT/conf/nginx/certificates - Select
designsafe.dev.crt - Search for designsafe and double click on Designsafe.dev
- Click on Trust and select "Trust Always"
- Close the window to save.
$ cd $PROJECT/conf/nginx/certificates$ sudo mkdir /usr/local/share/ca-certificates/extra$ sudo cp ca.pem /usr/local/share/ca-certificates/extra/designsafeCA.pem$ sudo update-ca-certificates
$ sudo dnf install ca-certificatesor$ sudo yum install ca-certificates$ sudo update-ca-trust enable$ cd $PROJECT/conf/nginx/certificates$ sudo cp ca.pem /usr/share/pki/ca-trust-source/anchors/designsafeCA.pemor$ sudo cp ca.pem /etc/pki/ca-trust/source/anchors/designsafeCA.pem$ sudo update-ca-trust
- Go to preferences
- Search for Authorities
- Click on "View Certificates" under "Certificates"
- On the Certificate Manager go to the "Authorities" tab
- Click on "Import..."
- Browse to
$PROJECT/conf/nginx/certificates - Select
ca.pem
sudo apt-get install libnss3-tools(or proper package manager)certutil -A -n "designsafeCA" -t "TCu,Cu,Tu" -i ca.pem -d ${DBDIR}$DBDIRdiffers from browser to browser for more info: Chromium: https://chromium.googlesource.com/chromium/src/+/master/docs/linux_cert_management.md Firefox: https://support.mozilla.org/en-US/kb/profiles-where-firefox-stores-user-data?redirectlocale=en-US&redirectslug=Profiles#How_to_find_your_profile
- Generate key and pem for root CA:
openssl req -x509 -sha256 -days 1825 -newkey rsa:2048 -keyout ca.key -out ca.crt(These files should already be in the repo, and valid for 5 years from time of creation) - Generate RSA-2048 key for local dev site and Cert Request (CSR):
openssl req -newkey rsa:2048 -noenc -keyout designsafe.dev.key -out designsafe.dev.csr(Common name should bedesignsafe.dev) - Generate certificate for local dev site:
openssl x509 -signkey designsafe.dev.key -in designsafe.dev.csr -req -days 365 -out designsafe.dev.crt - Make sure
designsafe.dev.extis correct - Sign Cert with root CA:
openssl x509 -req -CA ca.pem -CAkey ca.key -in designsafe.dev.csr -out designsafe.dev.crt -days 365 -CAcreateserial -extfile designsafe.dev.ext(Cert is valid for 365 days) - Files created:
designsafe.dev.key(site private key),designsafe.dev.csr(site certificate signing request),designsafe.dev.crt(actual site certificate),ca.key(CA private key) andca.pem(CA certificate).
DesignSafe custom apps should be put into designsafe/apps. You can then enable them in
the Django settings.py with designsafe.apps.{app_name}.
See the DesignSafe Styles Reference for style reference and custom CSS documentation.
This project uses Python Poetry to manage dependencies. To add a new dependency:
- Run
poetry add $NEW_DEPENDENCY. - Rebuild the dev image with
make build-dev
The easiest way to run the tests is from inside a running Docker container. While you can install all the Python/Django/npm dependencies locally (ideally within a virtualenv), this is already done in the docker container.
We assume you have the image built or checked out locally and it is called
des_django.
Django tests should be written according to standard Django testing procedures.
You can run Django tests with the following command:
$ docker exec -it des_django pytest -ra designsafeFrontend tests are Vitest tests executed using Nx.
To run frontend tests, run the command:
$ npm run testUse docker compose to run the portal in development. The default compose file,
docker-compose.yml runs the main django server in development
mode with a redis service for websockets support. You can optionally enable the EF sites
for testing.
$ make build-dev
$ make start
$ npm run start
$ docker run -v `pwd`:`pwd` -w `pwd` -it node:16 /bin/bash -c "npm run dev"When using this compose file, your Tapis Client should be configured with a callback_url
of http://$DOCKER_HOST_IP:8000/auth/tapis/callback/.
$ docker-compose -f docker-compose-http.yml build
$ docker-compose -f docker-compose-http.yml upProduction deployment is managed by Camino. See https://github.com/TACC/Camino.