dify icon indicating copy to clipboard operation
dify copied to clipboard

How to set ENV?

Open Leonard-Li777 opened this issue 1 year ago • 1 comments

Self Checks

  • [X] I have searched for existing issues search for existing issues, including closed ones.
  • [X] I confirm that I am using English to submit report (我已阅读并同意 Language Policy).
  • [X] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • [X] Please do not modify this template :) and fill in all the required fields.

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

Leonard-Li777 avatar Aug 11 '24 17:08 Leonard-Li777

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:

  • Persistent Environment Variables: The .env file ensures that your configurations persist across deployments.
  • Vector Database Configuration: You can switch between different vector databases by setting the VECTOR_STORE environment variable in your .env file to your desired service, such as milvus, weaviate, or opensearch.
  • Middleware Services: For setting up essential middleware services like databases and caches, use the docker-compose.middleware.yaml file and ensure the middleware.env file is created by running cp middleware.env.example middleware.env.

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.

dosubot[bot] avatar Aug 11 '24 17:08 dosubot[bot]

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

Leonard-Li777 avatar Aug 12 '24 17:08 Leonard-Li777

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

crazywoola avatar Aug 13 '24 01:08 crazywoola

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

Leonard-Li777 avatar Aug 13 '24 06:08 Leonard-Li777