langgenius / dify

Dify is an open-source LLM app development platform. Dify's intuitive interface combines AI workflow, RAG pipeline, agent capabilities, model management, observability features and more, letting you quickly go from prototype to production.
https://dify.ai
Other
49.73k stars 7.11k forks source link

How to set ENV? #7172

Closed Leonard-Li777 closed 2 months ago

Leonard-Li777 commented 2 months ago

Self Checks

Provide a description of requested docs changes

Whether I set.env in the api directory or the docker directory, the configuration does not take effect

docker compose down docker compose up -d

1723395548256_d 1723395599486_d 1723395791080_d

dosubot[bot] commented 2 months ago

To ensure that the environment variables are correctly set and applied in your Docker setup for the dify repository, follow these steps:

  1. Clone the Dify Repository:

    git clone https://github.com/langgenius/dify.git
  2. Navigate to the Docker Directory:

    cd dify/docker
  3. Copy the Example Environment File:

    cp .env.example .env
  4. Edit the .env File: Open the .env file in a text editor and customize the environment variable values as needed. Refer to the .env.example file for detailed configuration options.

  5. Start Dify with Docker Compose:

    docker compose up -d
  6. Restart Dify After Editing Environment Variables: If you make any changes to the .env file, restart Dify to apply the changes:

    docker compose down
    docker compose up -d

Additional Tips:

The full set of annotated environment variables can be found in the docker/.env.example file. Make sure to review and set these variables according to your requirements. For more detailed instructions, refer to the docker/README.md file in the repository [1][2][3][4].

Specific Instructions for the api Directory:

For the api directory, ensure you have set the environment variables in the .env file located in the api directory. Here are some key configurations:

  1. SECRET_KEY: Generate a strong key using openssl rand -base64 42 and set it in the SECRET_KEY environment variable.
  2. API URLs: Set the base URLs for various services.
  3. Celery and Redis Configuration: Set the CELERY_BROKER_URL and other Redis-related variables.
  4. Database Configuration: Set the PostgreSQL database connection details.
  5. Storage Configuration: Configure the storage type and related settings.
  6. CORS Configuration: Set allowed origins for CORS.
  7. Vector Database Configuration: Configure the vector database and its connection details.
  8. Upload Configuration: Set limits for file uploads.
  9. Mail Configuration: Configure the mail service.
  10. Sentry Configuration: Set the Sentry DSN.
  11. Debugging and Logging: Configure debugging and logging settings.
  12. Notion Import Configuration: Set Notion integration details.
  13. ETL and SSRF Proxy Configuration: Configure ETL and SSRF proxy settings.
  14. Batch Upload and Keyword Data Source Configuration: Set limits for batch uploads and keyword data sources.
  15. Code Execution Configuration: Set limits for code execution.
  16. API Tool and HTTP Node Configuration: Configure API tool and HTTP node settings.
  17. Indexing Configuration: Set the maximum segmentation tokens length.
  18. Workflow Runtime Configuration: Configure workflow execution limits.
  19. App Configuration: Set the maximum execution time for the app.

These configurations should be set in the .env file in the api directory based on your deployment requirements [5][6].

After setting the environment variables, restart the Docker containers to apply the changes:

docker compose down
docker compose up -d

To continue talking to Dosu, mention @dosu.

Leonard-Li777 commented 2 months ago

我的问题任然没有解决!我就是按照这个方式去做的,但是没有生效的,我的截图已经说明情况了!

crazywoola commented 2 months ago

Your image doesn't give any useful information, the API environment variables you modify won't work for Docker, and if you follow the documentation, your environment variables won't have just 4 lines. And you didn't say what you were going to do with the environment variables

Leonard-Li777 commented 2 months ago

Environment variables As I understand it, the ones that are not set will use the default value, right? I just want to set the maximum workflow execution time to 1 hour instead of the current 20 minutes, and it doesn't actually work whether I set the .env file in docker or the .env file in api

Your image doesn't give any useful information, the API environment variables you modify won't work for Docker, and if you follow the documentation, your environment variables won't have just 4 lines. And you didn't say what you were going to do with the environment variables