mirror of
https://github.com/goharbor/harbor.git
synced 2024-12-22 08:38:03 +01:00
commit
098643303f
@ -1,7 +0,0 @@
|
||||
# Logrotate configuartion file for docker.
|
||||
|
||||
/var/log/docker/*/*.log {
|
||||
rotate 100
|
||||
size 10M
|
||||
copytruncate
|
||||
}
|
26
make/common/log/rotate.sh
Executable file
26
make/common/log/rotate.sh
Executable file
@ -0,0 +1,26 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
echo "Log rotate starting..."
|
||||
|
||||
#The logs n days before will be compressed.
|
||||
n=14
|
||||
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."
|
@ -1,8 +1,7 @@
|
||||
FROM library/photon:latest
|
||||
|
||||
# run logrotate hourly, disable imklog model, provides TCP/UDP syslog reception
|
||||
RUN tdnf install -y cronie rsyslog logrotate shadow\
|
||||
&& mv /etc/cron.daily/logrotate /etc/cron.hourly/ \
|
||||
RUN tdnf install -y cronie rsyslog shadow tar gzip \
|
||||
&& mkdir /etc/rsyslog.d/ \
|
||||
&& mkdir /var/spool/rsyslog \
|
||||
&& groupadd syslog \
|
||||
@ -10,15 +9,13 @@ RUN tdnf install -y cronie rsyslog logrotate shadow\
|
||||
|
||||
ADD make/common/log/rsyslog.conf /etc/rsyslog.conf
|
||||
|
||||
COPY make/photon/log/logrotate.conf.photon /etc/logrotate.conf
|
||||
|
||||
# logrotate configuration file for docker
|
||||
ADD make/common/log/logrotate_docker.conf /etc/logrotate.d/
|
||||
# rotate logs weekly
|
||||
# notes: file name cannot contain dot, or the script will not run
|
||||
ADD make/common/log/rotate.sh /etc/cron.weekly/rotate
|
||||
|
||||
# rsyslog configuration file for docker
|
||||
ADD make/common/log/rsyslog_docker.conf /etc/rsyslog.d/
|
||||
|
||||
|
||||
VOLUME /var/log/docker/
|
||||
|
||||
EXPOSE 514
|
||||
|
@ -1,35 +0,0 @@
|
||||
# see "man logrotate" for details
|
||||
# rotate log files weekly
|
||||
weekly
|
||||
|
||||
# keep 4 weeks worth of backlogs
|
||||
rotate 4
|
||||
|
||||
# create new (empty) log files after rotating old ones
|
||||
create
|
||||
|
||||
# use date as a suffix of the rotated file
|
||||
dateext
|
||||
|
||||
# uncomment this if you want your log files compressed
|
||||
#compress
|
||||
|
||||
# RPM packages drop log rotation information into this directory
|
||||
include /etc/logrotate.d
|
||||
|
||||
# no packages own wtmp and btmp -- we'll rotate them here
|
||||
#/var/log/wtmp {
|
||||
# monthly
|
||||
# create 0664 root utmp
|
||||
# minsize 1M
|
||||
# rotate 1
|
||||
#}
|
||||
|
||||
/var/log/btmp {
|
||||
missingok
|
||||
monthly
|
||||
create 0600 root utmp
|
||||
rotate 1
|
||||
}
|
||||
|
||||
# system-specific logs may be also be configured here.
|
@ -1,13 +1,12 @@
|
||||
FROM library/ubuntu:14.04
|
||||
|
||||
# run logrotate hourly, disable imklog model, provides TCP/UDP syslog reception
|
||||
RUN mv /etc/cron.daily/logrotate /etc/cron.hourly/ \
|
||||
&& rm /etc/rsyslog.d/* \
|
||||
&& rm /etc/rsyslog.conf
|
||||
RUN rm /etc/rsyslog.d/* && rm /etc/rsyslog.conf
|
||||
|
||||
ADD make/common/log/rsyslog.conf /etc/rsyslog.conf
|
||||
|
||||
# logrotate configuration file for docker
|
||||
ADD make/common/log/logrotate_docker.conf /etc/logrotate.d/
|
||||
# rotate logs weekly
|
||||
# notes: file name cannot contain dot, or the script will not run
|
||||
ADD make/common/log/rotate.sh /etc/cron.weekly/rotate
|
||||
|
||||
# rsyslog configuration file for docker
|
||||
ADD make/common/log/rsyslog_docker.conf /etc/rsyslog.d/
|
||||
|
Loading…
Reference in New Issue
Block a user