Rasa_rasa_core - Error when trying to expand the environment variables in '${RASA_MODEL_SERVER}'. - docker-compose

Hi, Could anybody help me?

I´m trying make work rasa on a docker-compose but I get the error:

`/usr/local/lib/python3.6/runpy.py:125: RuntimeWarning: 'rasa_core.run' found in sys.modules after import of package 'rasa_core', but prior to execution of 'rasa_core.run'; this may result in unpredictable behaviour`

`warn(RuntimeWarning(msg))`

`2020-11-09 21:55:42 INFO root - Rasa process starting`

`Traceback (most recent call last):`

`File "/usr/local/lib/python3.6/runpy.py", line 193, in _run_module_as_main`

`"__main__", mod_spec)`

`File "/usr/local/lib/python3.6/runpy.py", line 85, in _run_code`

`exec(code, run_globals)`

`File "/app/rasa_core/run.py", line 194, in <module>`

`_endpoints = AvailableEndpoints.read_endpoints(cmdline_args.endpoints)`

`File "/app/rasa_core/utils.py", line 615, in read_endpoints`

`endpoint_file, endpoint_type="nlg")`

`File "/app/rasa_core/utils.py", line 537, in read_endpoint_config`

`content = read_yaml_file(filename)`

`File "/app/rasa_core/utils.py", line 316, in read_yaml_file`

`return read_yaml_string(read_file(filename))`

`File "/app/rasa_core/utils.py", line 327, in read_yaml_string`

`return yaml_parser.load(string) or {}`

`File "/usr/local/lib/python3.6/site-packages/ruamel/yaml/main.py", line 331, in load`

`return constructor.get_single_data()`

`File "/usr/local/lib/python3.6/site-packages/ruamel/yaml/constructor.py", line 111, in get_single_data`

`return self.construct_document(node)`

`File "/usr/local/lib/python3.6/site-packages/ruamel/yaml/constructor.py", line 121, in construct_document`

`for _dummy in generator:`

`File "/usr/local/lib/python3.6/site-packages/ruamel/yaml/constructor.py", line 699, in construct_yaml_map`

`value = self.construct_mapping(node)`

`File "/usr/local/lib/python3.6/site-packages/ruamel/yaml/constructor.py", line 426, in construct_mapping`

`return BaseConstructor.construct_mapping(self, node, deep=deep)`

`File "/usr/local/lib/python3.6/site-packages/ruamel/yaml/constructor.py", line 245, in construct_mapping`

`value = self.construct_object(value_node, deep=deep)`

`File "/usr/local/lib/python3.6/site-packages/ruamel/yaml/constructor.py", line 167, in construct_object`

`data = constructor(self, node)`

`File "/app/rasa_core/utils.py", line 308, in env_var_constructor`

`" variables: '{}'.".format(value, not_expanded))`

`ValueError: Error when trying to expand the environment variables in '${RASA_MODEL_SERVER}'. Please make sure to also set these environment variables: '['${RASA_MODEL_SERVER}']'.`

This is the content of my Docker File:

FROM python:3.7.9-slim

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

RUN apt-get update -qq && \
  apt-get install -y --no-install-recommends \
  build-essential \
  wget \
  openssh-client \
  graphviz-dev \
  pkg-config \
  git-core \
  openssl \
  libssl-dev \
  libffi6 \
  libffi-dev \
  libpng-dev \
  curl && \
  apt-get clean && \
  rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \
  mkdir /app

WORKDIR /app

# Copy as early as possible so we can cache ...
COPY requirements.txt .

RUN pip install -r requirements.txt --no-cache-dir

COPY . .

RUN pip install -e . --no-cache-dir

VOLUME ["/app/model", "/app/config", "/app/project", "/app/dialogue"]


# Make sure the default group has the same permissions as the owner
RUN chgrp -R 0 . && chmod -R g=u .

# Don't run as root
USER 1001

EXPOSE 5005

ENTRYPOINT ["./entrypoint.sh"]

CMD ["start", "-d", "./dialogue"]

My Docker-Compose.yml:

 rasa_core:
    image: rasa/rasa_core:${RASA_CORE_VERSION}
    networks: ['rasa-network']
    ports:
      - 5005:5005
    volumes:
      - ./models/rasa_core:/app/models
      - ./config:/app/config
      - ./dialogue:/app/dialogue
      - ./dialogue/domain.yml:/app/dialogue/domain.yml
    command:
      - start
      - --debug
      - --core
      - models
      - -c
      - rest
      - --endpoints
      - config/endpoints.yml
      - -u
      - current/

Thank you,

@amedinat, the rasa_core package is deprecated since 1.5 years. I highly recommend you to switch to Rasa Open Source 2.0 instead.

The error indicates that your endpoints.yml uses an environment variable (${env_name}) but your docker image does not have this environment variable set.

Hi Tobias,

Thanks for your answer. I Updated the docker-compose.yml file from the new documentation and now the rasa_production and rasa-worker show this error:

Starting Rasa X in production mode... 🚀
Could not fetch runtime config from server at 'http://rasa-x:5002/api/config?token=G@77@Ch@7607_x_token'. Exiting.
Starting Rasa X in production mode... 🚀
Could not fetch runtime config from server at 'http://rasa-x:5002/api/config?token=G@77@Ch@7607_x_token'. Exiting.
Starting Rasa X in production mode... 🚀
Could not fetch runtime config from server at 'http://rasa-x:5002/api/config?token=G@77@Ch@7607_x_token'. Exiting.
Starting Rasa X in production mode... 🚀
Could not fetch runtime config from server at 'http://rasa-x:5002/api/config?token=G@77@Ch@7607_x_token'. Exiting.
Starting Rasa X in production mode... 🚀
Could not fetch runtime config from server at 'http://rasa-x:5002/api/config?token=G@77@Ch@7607_x_token'. Exiting.
Starting Rasa X in production mode... 🚀
Could not fetch runtime config from server at 'http://rasa-x:5002/api/config?token=G@77@Ch@7607_x_token'. Exiting.

docker-compose:

 version: "3.4"

x-database-credentials: &database-credentials
  DB_HOST: "db"
  DB_PORT: "5432"
  DB_USER: "${DB_USER:-admin}"
  DB_PASSWORD: "${DB_PASSWORD}"
  DB_LOGIN_DB: "${DB_LOGIN_DB:-rasa}"

x-rabbitmq-credentials: &rabbitmq-credentials
  RABBITMQ_HOST: "rabbit"
  RABBITMQ_USERNAME: "user"
  RABBITMQ_PASSWORD: ${RABBITMQ_PASSWORD}

x-redis-credentials: &redis-credentials
  REDIS_HOST: "redis"
  REDIS_PORT: "6379"
  REDIS_PASSWORD: ${REDIS_PASSWORD}
  REDIS_DB: "1"

x-duckling-credentials: &duckling-credentials
  RASA_DUCKLING_HTTP_URL: "http://duckling:8000"

x-rasax-credentials: &rasax-credentials
  RASA_X_HOST: "http://rasa-x:5002"
  RASA_X_USERNAME: ${RASA_X_USERNAME:-admin}
  RASA_X_PASSWORD: ${RASA_X_PASSWORD:-}
  RASA_X_TOKEN: ${RASA_X_TOKEN}
  JWT_SECRET: ${JWT_SECRET}
  RASA_USER_APP: "http://app:5055"
  RASA_PRODUCTION_HOST: "http://rasa-production:5005"
  RASA_WORKER_HOST: "http://rasa-worker:5005"
  RASA_TOKEN: ${RASA_TOKEN}

x-rasa-credentials: &rasa-credentials
  <<: *rabbitmq-credentials
  <<: *rasax-credentials
  <<: *database-credentials
  <<: *redis-credentials
  <<: *duckling-credentials
  RASA_TOKEN: ${RASA_TOKEN}
  RASA_MODEL_PULL_INTERVAL: 10
  RABBITMQ_QUEUE: "rasa_production_events"
  RASA_TELEMETRY_ENABLED: ${RASA_TELEMETRY_ENABLED:-true}

x-rasa-services: &default-rasa-service
  restart: always
  image: "rasa/rasa:${RASA_VERSION}-full"
  volumes:
      - ./.config:/.config
  expose:
    - "5005"
  command: >
    x
    --no-prompt
    --production
    --config-endpoint http://rasa-x:5002/api/config?token=${RASA_X_TOKEN}
    --port 5005
    --jwt-method HS256
    --jwt-secret ${JWT_SECRET}
    --auth-token '${RASA_TOKEN}'
    --cors "*"
  depends_on:
    - rasa-x
    - rabbit
    - redis

services:
  rasa-x:
    restart: always
    image: "rasa/rasa-x:${RASA_X_VERSION}"
    expose:
      - "5002"
    volumes:
      - ./models:/app/models
      - ./environments.yml:/app/environments.yml
      - ./credentials.yml:/app/credentials.yml
      - ./endpoints.yml:/app/endpoints.yml
      - ./logs:/logs
      - ./auth:/app/auth
    environment:
      <<: *database-credentials
      <<: *rasa-credentials
      SELF_PORT: "5002"
      DB_DATABASE: "${DB_DATABASE:-rasa}"
      RASA_MODEL_DIR: "/app/models"
      PASSWORD_SALT: ${PASSWORD_SALT}
      RABBITMQ_QUEUE: "rasa_production_events"
      RASA_X_USER_ANALYTICS: "0"
      SANIC_RESPONSE_TIMEOUT: "3600"
      RUN_DATABASE_MIGRATION_AS_SEPARATE_SERVICE: "true"
    depends_on:
      - db

  db-migration:
    command: ["python", "-m", "rasax.community.services.db_migration_service"]
    restart: always
    image: "rasa/rasa-x:${RASA_X_VERSION}"
    healthcheck:
      test: ["CMD-SHELL", "curl -f http://localhost:8000/health || kill 1"]
      interval: 5s
      timeout: 1s
      retries: 3
      start_period: 2s
    expose:
      - "8000"
    environment:
      <<: *database-credentials
      RUN_DATABASE_MIGRATION_AS_SEPARATE_SERVICE: "true"
    depends_on:
      - db

  rasa-production:
    <<: *default-rasa-service
    environment:
      <<: *rasa-credentials
      RASA_ENVIRONMENT: "production"
      DB_DATABASE: "tracker"
      MPLCONFIGDIR: "/tmp/.matplotlib"
      RASA_MODEL_SERVER: "http://rasa-x:5002/api/projects/default/models/tags/production"

  rasa-worker:
    <<: *default-rasa-service
    environment:
      <<: *rasa-credentials
      RASA_ENVIRONMENT: "worker"
      DB_DATABASE: "worker_tracker"
      MPLCONFIGDIR: "/tmp/.matplotlib"
      RASA_MODEL_SERVER: "http://rasa-x:5002/api/projects/default/models/tags/production"

  app:
    restart: always
    image: "rasa/rasa-x-demo:${RASA_X_DEMO_VERSION}"
    expose:
      - "5055"
    depends_on:
      - rasa-production

  db:
    restart: always
    image: "bitnami/postgresql:11.9.0"
    expose:
      - "5432"
    environment:
      POSTGRESQL_USERNAME: "${DB_USER:-admin}"
      POSTGRESQL_PASSWORD: "${DB_PASSWORD}"
      POSTGRESQL_DATABASE: "${DB_DATABASE:-rasa}"
    volumes:
      - ./db:/bitnami/postgresql

  rabbit:
    restart: always
    image: "bitnami/rabbitmq:3.8.9"
    environment:
      RABBITMQ_HOST: "rabbit"
      RABBITMQ_USERNAME: "user"
      RABBITMQ_PASSWORD: ${RABBITMQ_PASSWORD}
      RABBITMQ_DISK_FREE_LIMIT: "{mem_relative, 0.1}"
    expose:
      - "5672"

  duckling:
    restart: always
    image: "rasa/duckling:0.1.6.4"
    expose:
      - "8000"
    command: ["duckling-example-exe", "--no-access-log", "--no-error-log"]

  nginx:
    restart: always
    image: "rasa/nginx:${RASA_X_VERSION}"
    ports:
      - "80:8080"
      - "443:8443"
    volumes:
      - ./certs:/opt/bitnami/certs
      - ./terms:/opt/bitnami/nginx/conf/bitnami/terms
    depends_on:
      - rasa-x
      - rasa-production
      - app

  redis:
    restart: always
    image: "bitnami/redis:6.0.8"
    environment:
      REDIS_PASSWORD: ${REDIS_PASSWORD}
    expose:
      - "6379"

Hi, finally I can see Rasa-x’s UI and it’s connected to github and synchronized, but there`s no model available. What could it be?

I can see NLU Data, Responses, Histories, Configuration, Domain… but no models.

Why it’s not synchronized? How can I generated a Model?

Thanks, John