enhancement logs output for container deployment (#1090)

This commit is contained in:
majinghe
2025-12-10 11:14:05 +08:00
committed by GitHub
parent ef261deef6
commit 8b3d4ea59b
5 changed files with 19 additions and 22 deletions

View File

@@ -81,12 +81,11 @@ ENV RUSTFS_ADDRESS=":9000" \
RUSTFS_CORS_ALLOWED_ORIGINS="*" \
RUSTFS_CONSOLE_CORS_ALLOWED_ORIGINS="*" \
RUSTFS_VOLUMES="/data" \
RUST_LOG="warn" \
RUSTFS_OBS_LOG_DIRECTORY="/logs"
RUST_LOG="warn"
EXPOSE 9000 9001
VOLUME ["/data", "/logs"]
VOLUME ["/data"]
USER rustfs

View File

@@ -166,14 +166,13 @@ ENV RUSTFS_ADDRESS=":9000" \
RUSTFS_CONSOLE_ENABLE="true" \
RUSTFS_VOLUMES="/data" \
RUST_LOG="warn" \
RUSTFS_OBS_LOG_DIRECTORY="/logs" \
RUSTFS_USERNAME="rustfs" \
RUSTFS_GROUPNAME="rustfs" \
RUSTFS_UID="1000" \
RUSTFS_GID="1000"
EXPOSE 9000
VOLUME ["/data", "/logs"]
VOLUME ["/data"]
# Keep root here; entrypoint will drop privileges using chroot --userspec
ENTRYPOINT ["/entrypoint.sh"]

View File

@@ -85,6 +85,7 @@ services:
- RUSTFS_ACCESS_KEY=devadmin
- RUSTFS_SECRET_KEY=devadmin
- RUSTFS_OBS_LOGGER_LEVEL=debug
- RUSTFS_OBS_LOG_DIRECTORY=/logs
volumes:
- .:/app # Mount source code to /app for development
- deploy/data/dev:/data
@@ -180,20 +181,6 @@ services:
profiles:
- observability
# Redis for caching (optional)
redis:
image: redis:7-alpine
container_name: redis
ports:
- "6379:6379"
volumes:
- redis_data:/data
networks:
- rustfs-network
restart: unless-stopped
profiles:
- cache
# NGINX reverse proxy (optional)
nginx:
security_opt:
@@ -241,7 +228,5 @@ volumes:
driver: local
grafana_data:
driver: local
redis_data:
driver: local
logs:
driver: local

View File

@@ -29,6 +29,7 @@ x-node-template: &node-template
- RUSTFS_ACCESS_KEY=rustfsadmin
- RUSTFS_SECRET_KEY=rustfsadmin
- RUSTFS_CMD=rustfs
- RUSTFS_OBS_LOG_DIRECTORY=/logs
command: [ "sh", "-c", "sleep 3 && rustfs" ]
healthcheck:
test:

View File

@@ -55,7 +55,20 @@ process_data_volumes() {
# 3) Process log directory (separate from data volumes)
process_log_directory() {
LOG_DIR="${RUSTFS_OBS_LOG_DIRECTORY:-/logs}"
# Output logs to stdout
if [ -z "$RUSTFS_OBS_LOG_DIRECTORY" ]; then
echo "OBS log directory not configured and logs outputs to stdout"
return
fi
# Output logs to remote endpoint
if [ "${RUSTFS_OBS_LOG_DIRECTORY}" != "${RUSTFS_OBS_LOG_DIRECTORY#*://}" ]; then
echo "Output logs to remote endpoint"
return
fi
# Outputs logs to local directory
LOG_DIR="${RUSTFS_OBS_LOG_DIRECTORY}"
echo "Initializing log directory: $LOG_DIR"
if [ ! -d "$LOG_DIR" ]; then