mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-20 17:25:24 +01:00
6f335bdb1a
This change involves using non-root user to run the process of the docker images. Also made update in Dockerfile to make the containers support "read-only" and introduce "HEALTHCHECK". Note the "read-only" options are not enabled in docker-compose, to cover the very corner case when user wants to update the container filesystem manually. Remove read only option from docker-compose template by default
34 lines
547 B
Bash
Executable File
34 lines
547 B
Bash
Executable File
#!/bin/bash
|
|
set -e
|
|
echo "Log rotate starting..."
|
|
|
|
#The logs n days before will be compressed.
|
|
n=$LOG_ROTATE_DAYS
|
|
if [ -z "$n" ]
|
|
then
|
|
n=3
|
|
fi
|
|
|
|
echo "logs rotate days: $n"
|
|
|
|
path=/var/log/docker
|
|
|
|
list=""
|
|
n_days_before=$(($(date +%s) - 3600*24*$n))
|
|
for dir in $(ls $path | grep -v "tar.gz");
|
|
do
|
|
if [ $(date --date=$dir +%s) -lt $n_days_before ]
|
|
then
|
|
echo "$dir will be compressed"
|
|
list="$list $dir"
|
|
fi
|
|
done
|
|
|
|
if [ -n "$list" ]
|
|
then
|
|
cd $path
|
|
tar --remove-files -zcvf $(date -d @$n_days_before +%F)-.tar.gz $list
|
|
fi
|
|
|
|
echo "Log rotate finished."
|