Skip to content

Help - How can we make this docker prod version#36

Description

@Pranith2003

Hi there,

we have local working code repo with Tethys React -- works fine 馃憤.

but, we are getting issue and errors related to tethysdash not found, init_primary_db return None Type, or database sync issue.

we are sure that tethys install alone is not helping to configure the whole app.
And please let's know which docker image should be used here!!..
we are using: tethysplatform/tethys-core:4.3.7-py3.12-dj4.2.

we want to use the postgres(17) inside a docker container.

Even if we have exposed 8000(tms), 8080(react) - those are not accessible with ip:ports (only accessible port 80)

For now,

  • 鉁卼ethys install --no-db-sync
  • 鉁卼ethys services create persistent -n primary_db -c :@:5432
  • 鉁卼ethys link persistent:primary_db tethysdash:ps_database:primary_db
  • 鉂宼ethys syncstores all
Error after running tethys syncstores all (even tried direct import)
Provisioning Persistent Stores...
INFO:tethys:Initializing database "primary_db" for app "tethysdash" with initializer "<function init_primary_db at 0x762220d58720>"...
Traceback (most recent call last):
  File "/usr/lib/tethys/tethys/tethys_apps/models.py", line 1222, in create_persistent_store_database
    self.initializer_function(
TypeError: 'NoneType' object is not callable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/tethys/tethys/tethys_portal/manage.py", line 20, in <module>
    execute_from_command_line(argv)
  File "/opt/conda/envs/tethys/lib/python3.12/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
    utility.execute()
  File "/opt/conda/envs/tethys/lib/python3.12/site-packages/django/core/management/__init__.py", line 436, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/opt/conda/envs/tethys/lib/python3.12/site-packages/django/core/management/base.py", line 412, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/opt/conda/envs/tethys/lib/python3.12/site-packages/django/core/management/base.py", line 458, in execute
    output = self.handle(*args, **options)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/tethys/tethys/tethys_apps/management/commands/syncstores.py", line 51, in handle
    self.provision_persistent_stores(options["app_name"], options)
  File "/usr/lib/tethys/tethys/tethys_apps/management/commands/syncstores.py", line 98, in provision_persistent_stores
    target_ps_db_setting.create_persistent_store_database(
  File "/usr/lib/tethys/tethys/tethys_apps/models.py", line 1227, in create_persistent_store_database
    raise PersistentStoreInitializerError(e)
tethys_apps.exceptions.PersistentStoreInitializerError: 'NoneType' object is not callable
(tethys) root@ce7327e2142d:/usr/lib/tethys/Tethys_react_app#
app.py (tried both initializer's but same above error)
from tethys_sdk.base import TethysAppBase
from tethys_sdk.app_settings import PersistentStoreDatabaseSetting
from .model import init_primary_db

class App(TethysAppBase):
    """
    Tethys app class for TethysDash.
    """

    name = "tethysdash"
    description = ""
    package = "tethysdash"  # WARNING: Do not change this value
    index = "home"
    icon = f"{package}/images/tethys_dash.png"
    catch_all = "home"  # required for react browser routing
    root_url = "tethysdash"
    color = ""  # Don't set color here, set it in reactapp/custom-bootstrap.scss
    tags = ""
    enable_feedback = False
    feedback_emails = []

    def persistent_store_settings(self):
        """
        Define Persistent Store Settings.
        """
        ps_settings = (
            PersistentStoreDatabaseSetting(
                name="primary_db",
                description="primary database",
                initializer="tethysdash.tethysdash.model.init_primary_db",
                #initializer=init_primary_db,
                required=True,
            ),
        )

        return ps_settings
docker-compose.yml (that pip install fixes the dependency error and start on port 80)
version: "3.8"

services:
  tethys:
    image: tethysplatform/tethys-core:4.3.7-py3.12-dj4.2
    # entrypoint: ["/bin/bash", "/Tethys_react_app/entrypoint.sh"] #didn't worked (gave error as tethys_cli not found)
    # pip install --upgrade daphne twisted
    container_name: tethys
    ports:
      - "80:80" #this is accessible only!!.. 
      - "8000:8000"
      - "8080:8080"
      - "3000:3000"
      - "4000:4000"
    environment:
      TETHYS_DB_SUPERUSER: postgres
      TETHYS_CONDA_ENV: tethys
      TETHYS_DB_PASSWORD: pass
      TETHYS_DB_PORT: 5432
      TETHYS_DB_HOST: postgres
      TETHYS_SUPERUSER: admin
      TETHYS_SUPERUSER_PASS: pass
    volumes:
      - .:/usr/lib/tethys/Tethys_react_app
      - ./deployment/portal_config.yml:/var/lib/tethys_persist/portal_config.yml
      - ./deployment/asgi_supervisord.conf:/var/lib/tethys_persist/asgi_supervisord.conf 
      - ./deployment/run.sh:/usr/lib/tethys/run.sh

    depends_on:
      postgres:
        condition: service_healthy
    networks:
      - tethys_network

  postgres:
    image: postgres:17
    container_name: tethys_db
    ports:
      - "5432:5432"
    environment:
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: pass
      POSTGRES_DB: tethys_platform
    volumes:
      - postgres_data:/var/lib/postgresql/data
    networks:
      - tethys_network
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U postgres"]
      interval: 5s
      timeout: 5s
      retries: 5

networks:
  tethys_network:

volumes:
  postgres_data:

And where should we copy(or mount) the codebase dir(Tethys_react_dash).

Since, after login (port 80) we aren't able to access the /apps/tethysdash/ as it's throwing 404 main.js file not found.

  • found a temp fix by replacing directory at /var/lib/tethys_persist/asgi_supervisord.conf -- is this the correct fix?

A detail steps would help us, glad if you share the external db setup!!.

Thanks!!..

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions