Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

adding LANG LC_ALL PYTHONIOENCODING UTF-8 (#22928)

znnd776a7cde797
diff --git a/api/.env.example b/api/.env.example
index 80b1c12cd89..18f2dbf647b 100644
--- a/api/.env.example
+++ b/api/.env.example
@@ -4,6 +4,11 @@
# Alternatively you can set it with `SECRET_KEY` environment variable.
SECRET_KEY=
+# Ensure UTF-8 encoding
+LANG=en_US.UTF-8
+LC_ALL=en_US.UTF-8
+PYTHONIOENCODING=utf-8
+
# Console API base URL
CONSOLE_API_URL=http://localhost:5001
CONSOLE_WEB_URL=http://localhost:3000
diff --git a/api/Dockerfile b/api/Dockerfile
index 8c7a1717b90..e097b5811e3 100644
--- a/api/Dockerfile
+++ b/api/Dockerfile
@@ -37,6 +37,11 @@ EXPOSE 5001
# set timezone
ENV TZ=UTC
+# Set UTF-8 locale
+ENV LANG=en_US.UTF-8
+ENV LC_ALL=en_US.UTF-8
+ENV PYTHONIOENCODING=utf-8
+
WORKDIR /app/api
RUN \
diff --git a/api/docker/entrypoint.sh b/api/docker/entrypoint.sh
index 4de9a25c2f9..a850ea9a507 100755
--- a/api/docker/entrypoint.sh
+++ b/api/docker/entrypoint.sh
@@ -2,6 +2,11 @@
set -e
+# Set UTF-8 encoding to address potential encoding issues in containerized environments
+export LANG=${LANG:-en_US.UTF-8}
+export LC_ALL=${LC_ALL:-en_US.UTF-8}
+export PYTHONIOENCODING=${PYTHONIOENCODING:-utf-8}
+
if [[ "${MIGRATION_ENABLED}" == "true" ]]; then
echo "Running migrations"
flask upgrade-db
diff --git a/docker/.env.example b/docker/.env.example
index 88cc544730f..9d15ba53d3f 100644
--- a/docker/.env.example
+++ b/docker/.env.example
@@ -52,6 +52,11 @@ FILES_URL=
# Example: INTERNAL_FILES_URL=http://api:5001
INTERNAL_FILES_URL=
+# Ensure UTF-8 encoding
+LANG=en_US.UTF-8
+LC_ALL=en_US.UTF-8
+PYTHONIOENCODING=utf-8
+
# ------------------------------
# Server Configuration
# ------------------------------
diff --git a/docker/docker-compose.yaml b/docker/docker-compose.yaml
index c2ef2ff7230..2c1429b5da9 100644
--- a/docker/docker-compose.yaml
+++ b/docker/docker-compose.yaml
@@ -12,6 +12,9 @@ x-shared-env: &shared-api-worker-env
APP_WEB_URL: ${APP_WEB_URL:-}
FILES_URL: ${FILES_URL:-}
INTERNAL_FILES_URL: ${INTERNAL_FILES_URL:-}
+ LANG: ${LANG:-en_US.UTF-8}
+ LC_ALL: ${LC_ALL:-en_US.UTF-8}
+ PYTHONIOENCODING: ${PYTHONIOENCODING:-utf-8}
LOG_LEVEL: ${LOG_LEVEL:-INFO}
LOG_FILE: ${LOG_FILE:-/app/logs/server.log}
LOG_FILE_MAX_SIZE: ${LOG_FILE_MAX_SIZE:-20}