mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-16 16:30:15 +01:00
💽 feat: Add CONSOLE_JSON for deploying to GCP K8S env (#2146)
* Add CONSOLE_JSON * Update example env * Moved to utils
This commit is contained in:
parent
57d1f12574
commit
d4b0af3dba
4 changed files with 90 additions and 17 deletions
27
.env.example
27
.env.example
|
|
@ -23,6 +23,13 @@ DOMAIN_SERVER=http://localhost:3080
|
||||||
|
|
||||||
NO_INDEX=true
|
NO_INDEX=true
|
||||||
|
|
||||||
|
#===============#
|
||||||
|
# JSON Logging #
|
||||||
|
#===============#
|
||||||
|
|
||||||
|
# Use when process console logs in cloud deployment like GCP/AWS
|
||||||
|
CONSOLE_JSON=false
|
||||||
|
|
||||||
#===============#
|
#===============#
|
||||||
# Debug Logging #
|
# Debug Logging #
|
||||||
#===============#
|
#===============#
|
||||||
|
|
@ -128,7 +135,7 @@ DEBUG_OPENAI=false
|
||||||
|
|
||||||
# OPENAI_REVERSE_PROXY=
|
# OPENAI_REVERSE_PROXY=
|
||||||
|
|
||||||
# OPENAI_ORGANIZATION=
|
# OPENAI_ORGANIZATION=
|
||||||
|
|
||||||
#====================#
|
#====================#
|
||||||
# Assistants API #
|
# Assistants API #
|
||||||
|
|
@ -317,15 +324,15 @@ OPENID_IMAGE_URL=
|
||||||
# Email Password Reset #
|
# Email Password Reset #
|
||||||
#========================#
|
#========================#
|
||||||
|
|
||||||
EMAIL_SERVICE=
|
EMAIL_SERVICE=
|
||||||
EMAIL_HOST=
|
EMAIL_HOST=
|
||||||
EMAIL_PORT=25
|
EMAIL_PORT=25
|
||||||
EMAIL_ENCRYPTION=
|
EMAIL_ENCRYPTION=
|
||||||
EMAIL_ENCRYPTION_HOSTNAME=
|
EMAIL_ENCRYPTION_HOSTNAME=
|
||||||
EMAIL_ALLOW_SELFSIGNED=
|
EMAIL_ALLOW_SELFSIGNED=
|
||||||
EMAIL_USERNAME=
|
EMAIL_USERNAME=
|
||||||
EMAIL_PASSWORD=
|
EMAIL_PASSWORD=
|
||||||
EMAIL_FROM_NAME=
|
EMAIL_FROM_NAME=
|
||||||
EMAIL_FROM=noreply@librechat.ai
|
EMAIL_FROM=noreply@librechat.ai
|
||||||
|
|
||||||
#========================#
|
#========================#
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,15 @@ const { redactFormat, redactMessage, debugTraverse } = require('./parsers');
|
||||||
|
|
||||||
const logDir = path.join(__dirname, '..', 'logs');
|
const logDir = path.join(__dirname, '..', 'logs');
|
||||||
|
|
||||||
const { NODE_ENV, DEBUG_LOGGING = true, DEBUG_CONSOLE = false } = process.env;
|
const { NODE_ENV, DEBUG_LOGGING = true, DEBUG_CONSOLE = false, CONSOLE_JSON = false } = process.env;
|
||||||
|
|
||||||
|
const useConsoleJson =
|
||||||
|
(typeof CONSOLE_JSON === 'string' && CONSOLE_JSON?.toLowerCase() === 'true') ||
|
||||||
|
CONSOLE_JSON === true;
|
||||||
|
|
||||||
|
const useDebugConsole =
|
||||||
|
(typeof DEBUG_CONSOLE === 'string' && DEBUG_CONSOLE?.toLowerCase() === 'true') ||
|
||||||
|
DEBUG_CONSOLE === true;
|
||||||
|
|
||||||
const levels = {
|
const levels = {
|
||||||
error: 0,
|
error: 0,
|
||||||
|
|
@ -33,7 +41,7 @@ const level = () => {
|
||||||
|
|
||||||
const fileFormat = winston.format.combine(
|
const fileFormat = winston.format.combine(
|
||||||
redactFormat(),
|
redactFormat(),
|
||||||
winston.format.timestamp({ format: 'YYYY-MM-DD HH:mm:ss' }),
|
winston.format.timestamp({ format: () => new Date().toISOString() }),
|
||||||
winston.format.errors({ stack: true }),
|
winston.format.errors({ stack: true }),
|
||||||
winston.format.splat(),
|
winston.format.splat(),
|
||||||
// redactErrors(),
|
// redactErrors(),
|
||||||
|
|
@ -99,14 +107,20 @@ const consoleFormat = winston.format.combine(
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
if (
|
if (useDebugConsole) {
|
||||||
(typeof DEBUG_CONSOLE === 'string' && DEBUG_CONSOLE?.toLowerCase() === 'true') ||
|
|
||||||
DEBUG_CONSOLE === true
|
|
||||||
) {
|
|
||||||
transports.push(
|
transports.push(
|
||||||
new winston.transports.Console({
|
new winston.transports.Console({
|
||||||
level: 'debug',
|
level: 'debug',
|
||||||
format: winston.format.combine(fileFormat, debugTraverse),
|
format: useConsoleJson
|
||||||
|
? winston.format.combine(fileFormat, debugTraverse, winston.format.json())
|
||||||
|
: winston.format.combine(fileFormat, debugTraverse),
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
} else if (useConsoleJson) {
|
||||||
|
transports.push(
|
||||||
|
new winston.transports.Console({
|
||||||
|
level: 'info',
|
||||||
|
format: winston.format.combine(fileFormat, winston.format.json()),
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
21
utils/docker/docker-build.sh
Executable file
21
utils/docker/docker-build.sh
Executable file
|
|
@ -0,0 +1,21 @@
|
||||||
|
#!/bin/bash
|
||||||
|
[ "$1" = -x ] && shift && set -x
|
||||||
|
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
|
||||||
|
cd ${DIR}/../..
|
||||||
|
|
||||||
|
TAG=$1
|
||||||
|
|
||||||
|
if [[ -z "${TAG}" ]]; then
|
||||||
|
TAG=${LIBRE_CHAT_DOCKER_TAG}
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -z "${TAG}" ]]; then
|
||||||
|
TAG=latest
|
||||||
|
fi
|
||||||
|
|
||||||
|
LOCAL_DOCKER_IMG=librechat:${TAG}
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
docker build -t ${LOCAL_DOCKER_IMG} .
|
||||||
31
utils/docker/docker-push.sh
Executable file
31
utils/docker/docker-push.sh
Executable file
|
|
@ -0,0 +1,31 @@
|
||||||
|
#!/bin/bash
|
||||||
|
[ "$1" = -x ] && shift && set -x
|
||||||
|
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
|
||||||
|
cd ${DIR}/../..
|
||||||
|
|
||||||
|
TAG=$1
|
||||||
|
|
||||||
|
if [[ -z "${TAG}" ]]; then
|
||||||
|
TAG=${LIBRE_CHAT_DOCKER_TAG}
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -z "${TAG}" ]]; then
|
||||||
|
TAG=latest
|
||||||
|
fi
|
||||||
|
|
||||||
|
LOCAL_DOCKER_IMG=librechat:${TAG}
|
||||||
|
|
||||||
|
if [[ -z "${DOCKER_REMOTE_REGISTRY}" ]]; then
|
||||||
|
echo "DOCKER_REMOTE_REGISTRY is not set" >&2
|
||||||
|
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
REMOTE_DOCKER_IMG=${DOCKER_REMOTE_REGISTRY}/${LOCAL_DOCKER_IMG}
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
docker tag ${LOCAL_DOCKER_IMG} ${REMOTE_DOCKER_IMG}
|
||||||
|
|
||||||
|
docker push ${REMOTE_DOCKER_IMG}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue