How to set api key in docker container?

Error message

I’m getting error above once I try to send email using sendgrid api in a custom action. I believe this is caused by that I don’t provide api key, but how do I set api key to docker container? I have .env in the root directory has api key value. Can it be done at dockerfile or docker-compose.yml? @nik202

Dockerfile

FROM rasa/rasa-sdk:2.8.2

WORKDIR /app

COPY . /app/actions

USER root
RUN pip install --no-cache-dir -r /app/actions/requirements-actions.txt

USER 1001
CMD ["start", "--actions", "actions"]

I believe you have to explicitly set the environment name you have in .env in your docker-compose.

Ex: .env

SENDGRID_API_KEY="your-api-key"

Ex: docker-compose.yml

services:
  rasa-action:
    build:
      context: .
      dockerfile: Dockerfile.action
    environment:
      SENDGRID_API_KEY: ${SENDGRID_API_KEY}
1 Like

That works. Thanks for the help!