Skip to content

Commit

Permalink
Merge branch 'main' into add_media
Browse files Browse the repository at this point in the history
  • Loading branch information
gagelarsen committed Apr 15, 2024
2 parents 5b41419 + 9d5c55b commit 7302123
Show file tree
Hide file tree
Showing 163 changed files with 1,193 additions and 995 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/tethys-release.yml
Expand Up @@ -137,7 +137,7 @@ jobs:
cd ..
. ~/miniconda/etc/profile.d/conda.sh;
conda activate tethys;
tethys gen metayaml -p minor --overwrite;
tethys gen metayaml -p ${CONDA_BUILD_PIN_LEVEL} --overwrite;
# Show Tethys Meta
- name: Show Tethys Meta
run: |
Expand Down Expand Up @@ -179,7 +179,7 @@ jobs:
cd ..
. ~/miniconda/etc/profile.d/conda.sh;
conda activate tethys;
tethys gen metayaml -p minor --micro --overwrite;
tethys gen metayaml -p ${CONDA_BUILD_PIN_LEVEL} --micro --overwrite;
# Show Tethys Meta
- name: Show Tethys Meta - micro
run: |
Expand Down
35 changes: 24 additions & 11 deletions Dockerfile
Expand Up @@ -3,6 +3,7 @@ FROM mambaorg/micromamba:bullseye
# BUILD ARGUMENTS #
###################
ARG PYTHON_VERSION=3.*
ARG MICRO_TETHYS=false

###############
# ENVIRONMENT #
Expand All @@ -14,6 +15,7 @@ ENV TETHYS_APPS_ROOT="/var/www/tethys/apps"
ENV TETHYS_PORT=8000
ENV NGINX_PORT=80
ENV POSTGRES_PASSWORD="pass"
ENV SKIP_DB_SETUP=false
ENV TETHYS_DB_ENGINE='django.db.backends.postgresql'
ENV TETHYS_DB_NAME='tethys_platform'
ENV TETHYS_DB_USERNAME="tethys_default"
Expand Down Expand Up @@ -114,14 +116,14 @@ RUN echo "force-unsafe-io" > /etc/dpkg/dpkg.cfg.d/02apt-speedup \

# Install APT packages
RUN rm -rf /var/lib/apt/lists/*\
&& apt-get update \
&& apt-get -y install curl \
&& mkdir /etc/apt/keyrings \
&& curl -fsSL -o /etc/apt/keyrings/salt-archive-keyring-2023.gpg https://repo.saltproject.io/salt/py3/debian/11/amd64/SALT-PROJECT-GPG-PUBKEY-2023.gpg \
&& echo "deb [signed-by=/etc/apt/keyrings/salt-archive-keyring-2023.gpg arch=amd64] https://repo.saltproject.io/salt/py3/debian/11/amd64/latest bullseye main" | tee /etc/apt/sources.list.d/salt.list \
&& apt-get update \
&& apt-get -y install bzip2 git nginx supervisor gcc salt-minion procps pv \
&& rm -rf /var/lib/apt/lists/*
&& apt-get update \
&& apt-get -y install curl \
&& mkdir /etc/apt/keyrings \
&& curl -fsSL -o /etc/apt/keyrings/salt-archive-keyring-2023.gpg https://repo.saltproject.io/salt/py3/debian/11/amd64/SALT-PROJECT-GPG-PUBKEY-2023.gpg \
&& echo "deb [signed-by=/etc/apt/keyrings/salt-archive-keyring-2023.gpg arch=amd64] https://repo.saltproject.io/salt/py3/debian/11/amd64/latest bullseye main" | tee /etc/apt/sources.list.d/salt.list \
&& apt-get update \
&& apt-get -y install bzip2 git nginx supervisor gcc salt-minion procps pv \
&& rm -rf /var/lib/apt/lists/*

# Remove default NGINX site
RUN rm -f /etc/nginx/sites-enabled/default
Expand All @@ -132,10 +134,21 @@ RUN ln -s /bin/micromamba ${CONDA_HOME}/bin/conda

# Setup Conda Environment
COPY --chown=$MAMBA_USER:$MAMBA_USER environment.yml ${TETHYS_HOME}/tethys/
COPY --chown=$MAMBA_USER:$MAMBA_USER micro_environment.yml ${TETHYS_HOME}/tethys/

WORKDIR ${TETHYS_HOME}/tethys
RUN sed -i "s/- python$/- python=${PYTHON_VERSION}/g" environment.yml \
&& micromamba create -n "${CONDA_ENV_NAME}" --yes --file "environment.yml" \
&& micromamba clean --all --yes

RUN if [ "${MICRO_TETHYS}" = "true" ]; then \
sed -i "s/- python$/- python=${PYTHON_VERSION}/g" micro_environment.yml && \
micromamba create -n "${CONDA_ENV_NAME}" --yes --file "micro_environment.yml" && \
micromamba clean --all --yes && \
rm -rf environment.yml; \
else \
sed -i "s/- python$/- python=${PYTHON_VERSION}/g" environment.yml && \
micromamba create -n "${CONDA_ENV_NAME}" --yes --file "environment.yml" && \
micromamba clean --all --yes && \
rm -rf micro_environment.yml; \
fi

###########
# INSTALL #
Expand Down
50 changes: 31 additions & 19 deletions docker/run.sh
Expand Up @@ -12,6 +12,8 @@ db_max_count=24;
no_daemon=true;
skip_perm=false;
test=false;
db_engine=${TETHYS_DB_ENGINE} # Get the DB engine from environment variable
skip_db_setup=${SKIP_DB_SETUP} # Get the DB setup flag from environment variable
USAGE="USAGE: . run.sh [options]
OPTIONS:
--background \t run supervisord in background.
Expand Down Expand Up @@ -44,32 +46,42 @@ done

echo_status "Starting up..."

# Create Salt Config
echo "file_client: local" > /etc/salt/minion
echo "postgres.host: '${TETHYS_DB_HOST}'" >> /etc/salt/minion
echo "postgres.port: '${TETHYS_DB_PORT}'" >> /etc/salt/minion
echo "postgres.user: '${TETHYS_DB_USERNAME}'" >> /etc/salt/minion
echo "postgres.pass: '${TETHYS_DB_PASSWORD}'" >> /etc/salt/minion
echo "postgres.bins_dir: '${CONDA_HOME}/envs/${CONDA_ENV_NAME}/bin'" >> /etc/salt/minion

if [[ $test = false ]]; then
# Set extra ENVs
export NGINX_USER=$(grep 'user .*;' /etc/nginx/nginx.conf | awk '{print $2}' | awk -F';' '{print $1}')

# Apply States
echo_status "Checking if DB is ready"

db_check_count=0

until ${CONDA_HOME}/envs/${CONDA_ENV_NAME}/bin/pg_isready -h ${TETHYS_DB_HOST} -p ${TETHYS_DB_PORT} -U postgres; do
if [[ $db_check_count -gt $db_max_count ]]; then
>&2 echo "DB was not available in time - exiting"
exit 1
if [[ $skip_db_setup != true ]]; then
echo_status "Checking if DB is ready"
if [[ $db_engine == "django.db.backends.postgresql" ]]; then
# Create Salt Config for PostgreSQL
echo "postgres.host: '${TETHYS_DB_HOST}'" >> /etc/salt/minion
echo "postgres.port: '${TETHYS_DB_PORT}'" >> /etc/salt/minion
echo "postgres.user: '${TETHYS_DB_USERNAME}'" >> /etc/salt/minion
echo "postgres.pass: '${TETHYS_DB_PASSWORD}'" >> /etc/salt/minion
echo "postgres.bins_dir: '${CONDA_HOME}/envs/${CONDA_ENV_NAME}/bin'" >> /etc/salt/minion

db_check_count=0

until ${CONDA_HOME}/envs/${CONDA_ENV_NAME}/bin/pg_isready -h ${TETHYS_DB_HOST} -p ${TETHYS_DB_PORT} -U postgres; do
if [[ $db_check_count -gt $db_max_count ]]; then
>&2 echo "DB was not available in time - exiting"
exit 1
fi
>&2 echo "DB is unavailable - sleeping"
db_check_count=`expr $db_check_count + 1`
sleep 5
done


else
echo_status "Using SQLite3 as the database"
fi
>&2 echo "DB is unavailable - sleeping"
db_check_count=`expr $db_check_count + 1`
sleep 5
done
else
# Database setup should be skipped
echo "Skipping database setup: check SKIP_DB_SETUP environment variable."
fi
fi

echo_status "Enforcing start state... (This might take a bit)"
Expand Down
31 changes: 22 additions & 9 deletions docker/salt/tethyscore.sls
Expand Up @@ -14,6 +14,7 @@
{% set POSTGRES_PASSWORD = salt['environ.get']('POSTGRES_PASSWORD') %}
{% set TETHYS_DB_PORT = salt['environ.get']('TETHYS_DB_PORT') %}
{% set TETHYS_DB_USERNAME = salt['environ.get']('TETHYS_DB_USERNAME') %}
{% set SKIP_DB_SETUP = salt['environ.get']('SKIP_DB_SETUP') %}
{% set TETHYS_HOME = salt['environ.get']('TETHYS_HOME') %}
{% set TETHYS_PORT = salt['environ.get']('TETHYS_PORT') %}
{% set OTHER_SETTINGS = salt['environ.get']('OTHER_SETTINGS') %}
Expand Down Expand Up @@ -72,20 +73,12 @@

{% set TETHYS_SITE_CONTENT = TETHYS_SITE_CONTENT_LIST|join(' ') %}



Generate_Tethys_Settings_TethysCore:
cmd.run:
- name: >
tethys settings
--set DEBUG {{ DEBUG }}
--set ALLOWED_HOSTS {{ ALLOWED_HOSTS }}
--set DATABASES.default.ENGINE "{{ TETHYS_DB_ENGINE }}"
--set DATABASES.default.NAME "{{ TETHYS_DB_NAME }}"
--set DATABASES.default.USER "{{ TETHYS_DB_USERNAME }}"
--set DATABASES.default.PASSWORD "{{ TETHYS_DB_PASSWORD }}"
--set DATABASES.default.HOST "{{ TETHYS_DB_HOST }}"
--set DATABASES.default.PORT "{{ TETHYS_DB_PORT }}"
--set INSTALLED_APPS {{ ADD_DJANGO_APPS }}
--set SESSION_CONFIG.SECURITY_WARN_AFTER {{ SESSION_WARN }}
--set SESSION_CONFIG.SECURITY_EXPIRE_AFTER {{ SESSION_EXPIRE }}
Expand All @@ -102,6 +95,24 @@ Generate_Tethys_Settings_TethysCore:
--set CHANNEL_LAYERS.default.CONFIG {{ CHANNEL_LAYERS_CONFIG }}
--set CAPTCHA_CONFIG.RECAPTCHA_PRIVATE_KEY "{{ RECAPTCHA_PRIVATE_KEY }}"
--set CAPTCHA_CONFIG.RECAPTCHA_PUBLIC_KEY "{{ RECAPTCHA_PUBLIC_KEY }}"
{%- if TETHYS_DB_ENGINE %}
--set DATABASES.default.ENGINE "{{ TETHYS_DB_ENGINE }}"
{%- endif %}
{%- if TETHYS_DB_NAME %}
--set DATABASES.default.NAME "{{ TETHYS_DB_NAME }}"
{%- endif %}
{%- if TETHYS_DB_USERNAME %}
--set DATABASES.default.USER "{{ TETHYS_DB_USERNAME }}"
{%- endif %}
{%- if TETHYS_DB_PASSWORD %}
--set DATABASES.default.PASSWORD "{{ TETHYS_DB_PASSWORD }}"
{%- endif %}
{%- if TETHYS_DB_HOST %}
--set DATABASES.default.HOST "{{ TETHYS_DB_HOST }}"
{%- endif %}
{%- if TETHYS_DB_PORT %}
--set DATABASES.default.PORT "{{ TETHYS_DB_PORT }}"
{%- endif %}
{{ OTHER_SETTINGS }}
- unless: /bin/bash -c "[ -f "{{ TETHYS_PERSIST }}/setup_complete" ];"

Expand Down Expand Up @@ -144,6 +155,7 @@ Generate_ASGI_Service_TethysCore:
- replace: False
- makedirs: True

{% if TETHYS_DB_ENGINE == 'django.db.backends.postgresql' %}
Create_Database_User_and_SuperUser_TethysCore:
cmd.run:
- name: >
Expand All @@ -153,7 +165,8 @@ Create_Database_User_and_SuperUser_TethysCore:
-N "{{ TETHYS_DB_SUPERUSER }}"
-P "{{ TETHYS_DB_SUPERUSER_PASS }}"
- shell: /bin/bash
- unless: /bin/bash -c "[ -f "{{ TETHYS_PERSIST }}/setup_complete" ];"
- unless: /bin/bash -c "[ -f '{{ TETHYS_PERSIST }}/setup_complete' ] || {{ SKIP_DB_SETUP | lower }};"
{% endif %}
Migrate_Database_TethysCore:
cmd.run:
Expand Down
56 changes: 30 additions & 26 deletions docs/installation/production/docker/tethys_docker_reference.rst
Expand Up @@ -98,6 +98,8 @@ Use these build arguments with the ``build`` command to customize how the image
+===========================+==========================================================================================+
| PYTHON_VERSION | The version of Python to build the Tethys environment with. Defaults to "3.*". |
+---------------------------+------------------------------------------------------------------------------------------+
| MICRO_TETHYS | Set to True to use `micro-tethys` environment. Defaults to False. |
+---------------------------+------------------------------------------------------------------------------------------+

Important Paths
---------------
Expand Down Expand Up @@ -142,32 +144,34 @@ Database Parameters

These environment variables are used to configure the database and database users Tethys Portal will use. If the database doesn't exist, then it will be created using the ``postgres`` user.

+---------------------------+------------------------------------------------------------------------------------------+
| Environment Variable | Description |
+===========================+==========================================================================================+
| POSTGRES_PASSWORD | Password of the postgres user. Used to initialize the Tethys Portal database. |
| | Defaults to "pass". |
+---------------------------+------------------------------------------------------------------------------------------+
| TETHYS_DB_HOST | Host of the database server where the primary Tethys Portal database resides. |
| | Defaults to "db". |
+---------------------------+------------------------------------------------------------------------------------------+
| TETHYS_DB_PORT | Port of the database server where the primary Tethys Portal database resides. |
| | Defaults to "5432". |
+---------------------------+------------------------------------------------------------------------------------------+
| TETHYS_DB_ENGINE | Type of database backend to use for the primary Tethys Portal database. |
| | Defaults to "django.db.backends.postgresql". |
+---------------------------+------------------------------------------------------------------------------------------+
| TETHYS_DB_NAME | Name of the primary Tethys Portal database. Defaults to "tethys_platform". |
+---------------------------+------------------------------------------------------------------------------------------+
| TETHYS_DB_USERNAME | Username of the owner of the primary Tethys Portal database. |
| | Defaults to "tethys_default". |
+---------------------------+------------------------------------------------------------------------------------------+
| TETHYS_DB_PASSWORD | Password of the owner of the primary Tethys Portal database. Defaults to "pass". |
+---------------------------+------------------------------------------------------------------------------------------+
| TETHYS_DB_SUPERUSER | Name of the database superuser used by Tethys Portal. Defaults to "tethys_super". |
+---------------------------+------------------------------------------------------------------------------------------+
| TETHYS_DB_SUPERUSER_PASS | Password of the database superuser used by Tethys Portal. Defaults to "pass". |
+---------------------------+------------------------------------------------------------------------------------------+
+--------------------------+-------------------------------------------------------------------------------------------------------------------------------------+
| Environment Variable | Description |
+==========================+=====================================================================================================================================+
|| POSTGRES_PASSWORD || Password of the postgres user. Used to initialize the Tethys Portal database. |
|| || Defaults to "pass". |
+--------------------------+-------------------------------------------------------------------------------------------------------------------------------------+
|| TETHYS_DB_HOST || Host of the database server where the primary Tethys Portal database resides. |
|| || Defaults to "db". |
+--------------------------+-------------------------------------------------------------------------------------------------------------------------------------+
|| TETHYS_DB_PORT || Port of the database server where the primary Tethys Portal database resides. |
|| || Defaults to "5432". |
+--------------------------+-------------------------------------------------------------------------------------------------------------------------------------+
|| TETHYS_DB_ENGINE || Type of database backend to use for the primary Tethys Portal database. |
|| || Defaults to "django.db.backends.postgresql". |
+--------------------------+-------------------------------------------------------------------------------------------------------------------------------------+
| TETHYS_DB_NAME | Name of the primary Tethys Portal database. Defaults to "tethys_platform". |
+--------------------------+-------------------------------------------------------------------------------------------------------------------------------------+
|| TETHYS_DB_USERNAME || Username of the owner of the primary Tethys Portal database. |
|| || Defaults to "tethys_default". |
+--------------------------+-------------------------------------------------------------------------------------------------------------------------------------+
| TETHYS_DB_PASSWORD | Password of the owner of the primary Tethys Portal database. Defaults to "pass". |
+--------------------------+-------------------------------------------------------------------------------------------------------------------------------------+
| TETHYS_DB_SUPERUSER | Name of the database superuser used by Tethys Portal. Defaults to "tethys_super". |
+--------------------------+-------------------------------------------------------------------------------------------------------------------------------------+
| TETHYS_DB_SUPERUSER_PASS | Password of the database superuser used by Tethys Portal. Defaults to "pass". |
+--------------------------+-------------------------------------------------------------------------------------------------------------------------------------+
| SKIP_DB_SETUP | Set to True to skip database creation, useful for existing databases configured for Tethys. Defaults to False. |
+--------------------------+-------------------------------------------------------------------------------------------------------------------------------------+

Tethys Portal Admin User
------------------------
Expand Down
2 changes: 1 addition & 1 deletion docs/tethys_portal/admin_pages.rst
Expand Up @@ -309,7 +309,7 @@ Proxy apps are links to external web applications or websites. They are represen

* **Name**: The name of the app that will appear on the app tile on the Apps Library page (e.g.: "My Proxy App").
* **Endpoint**: The URL that will be opened when the user clicks on the app tile of the proxy app (e.g.: ``https://my.proxy.app/foo/``).
* **Logo url**: The URL of the image that will be displayed on the app tile of the Proxy App (e.g.: ``https://my.proxy.app/static/foo-logo.org``).
* **Icon**: Override the icon/logo of the proxy app with a different icon. Accepts a relative path to a static file (e.g.: ``my-first-app/images/other-logo.png``) or a URL to an externally hosted image (e.g.: ``https://some.other-site.org/static/other-logo.png``).
* **Back url**: A URL to suggest as the back URL; usually points to the referring portal. If the Proxy App is a Tethys App on another Tethys Portal (>4.0.0), the Exit button for the app will be set to this URL (e.g.: ``https://this.portal.org/apps/``).
* **Description**: A description of the app that will be displayed when the user clicks on the info icon on the app tile.
* **Tags**: One or more tags for an app. Wrap each tag in double quotes and separate by commas (e.g.: ``"Hydrology","Grided Data","THREDDS"``).
Expand Down
8 changes: 7 additions & 1 deletion docs/tethys_sdk/app_class.rst
Expand Up @@ -104,4 +104,10 @@ Class Methods

.. automethod:: tethys_apps.base.TethysAppBase.create_persistent_store

.. automethod:: tethys_apps.base.TethysAppBase.drop_persistent_store
.. automethod:: tethys_apps.base.app_base.TethysAppBase.render

.. automethod:: tethys_apps.base.app_base.TethysBase.redirect

.. automethod:: tethys_apps.base.app_base.TethysBase.reverse

.. automethod:: tethys_apps.base.app_base.TethysBase.render_to_string

0 comments on commit 7302123

Please sign in to comment.