Skip to content

Commit 8705221

Browse files
issue zulip#263
1 parent f445fc5 commit 8705221

File tree

7 files changed

+106
-0
lines changed

7 files changed

+106
-0
lines changed

Diff for: .dockerignore

+4
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,7 @@ TODO.md
99
kubernetes/
1010
scripts/
1111
docker-compose.yml
12+
logs/
13+
supervisor-logs/
14+
zulip-data/
15+

Diff for: Dockerfile

+14
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,20 @@
33
# tools/build-release-tarball to generate a production release tarball
44
# from the provided Git ref.
55
FROM ubuntu:24.04 AS base
6+
# Install required packages
7+
RUN apt-get update && apt-get install -y \
8+
logrotate \
9+
cron \
10+
&& rm -rf /var/lib/apt/lists/*
11+
12+
# Copy logrotate configuration
13+
COPY zulip-docker /etc/logrotate.d/zulip-docker
14+
RUN chmod 644 /etc/logrotate.d/zulip-docker
15+
16+
# Set up log directories with proper permissions
17+
RUN mkdir -p /var/log/zulip /var/log/supervisor \
18+
&& chown -R zulip:zulip /var/log/zulip \
19+
&& chmod 755 /var/log/zulip
620

721
# Set up working locales and upgrade the base image
822
ENV LANG="C.UTF-8"

Diff for: docker-compose.yml

+7
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,14 @@ services:
9797
# comma-separated set of IP addresses to trust here.
9898
# LOADBALANCER_IPS: "",
9999
volumes:
100+
- ./logs:/var/log/zulip:rw
101+
- ./supervisor-logs:/var/log/supervisor:rw
100102
- "zulip:/data:rw"
103+
depends_on:
104+
- database
105+
- memcached
106+
- rabbitmq
107+
- redis
101108
ulimits:
102109
nofile:
103110
soft: 1000000

Diff for: entrypoint.sh

+13
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,24 @@
11
#!/bin/bash
2+
set -e
23

34
if [ "$DEBUG" = "true" ] || [ "$DEBUG" = "True" ]; then
45
set -x
56
set -o functrace
67
fi
78
set -e
89
shopt -s extglob
10+
# === ADD NEW LOG ROTATION CODE RIGHT HERE ===
11+
echo "Setting up log rotation..."
12+
service cron start
13+
touch /var/lib/logrotate/status
14+
15+
echo "Creating log directories..."
16+
mkdir -p /var/log/zulip /var/log/supervisor
17+
18+
echo "Setting correct permissions..."
19+
chown -R zulip:zulip /var/log/zulip
20+
chmod 755 /var/log/zulip
21+
# === END OF NEW LOG ROTATION CODE ===
922

1023
# DB aka Database
1124
DB_HOST="${DB_HOST:-127.0.0.1}"

Diff for: etc/logrotate.d.d/zulip-docker

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
docker exec -it zulip bash -c 'cat > /etc/logrotate.d/zulip-docker' << 'EOF'
2+
/var/log/zulip/*.log {
3+
daily
4+
rotate 7
5+
compress
6+
delaycompress
7+
notifempty
8+
missingok
9+
create 644 zulip zulip
10+
sharedscripts
11+
postrotate
12+
supervisorctl reopen-logs
13+
endscript
14+
}
15+
16+
/var/log/supervisor/*.log {
17+
daily
18+
rotate 7
19+
compress
20+
delaycompress
21+
notifempty
22+
missingok
23+
create 644 root root
24+
sharedscripts
25+
postrotate
26+
supervisorctl reopen-logs
27+
endscript
28+
}
29+
EOF

Diff for: etc/logrotate.d/zulip

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/var/log/zulip/server.log
2+
/var/log/zulip/workers.log
3+
/var/log/zulip/errors.log
4+
{
5+
rotate 7
6+
daily
7+
missingok
8+
compress
9+
delaycompress
10+
notifempty
11+
create 644 zulip zulip
12+
sharedscripts
13+
postrotate
14+
/usr/bin/supervisorctl reopen-logs
15+
endscript
16+
}

Diff for: etc/supervisor/conf.d/zulip.conf

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
[supervisord]
2+
nodaemon=true
3+
logfile=/var/log/supervisor/supervisord.log
4+
logfile_maxbytes=50MB
5+
logfile_backups=10
6+
loglevel=info
7+
8+
[program:zulip]
9+
command=/usr/local/bin/zulip start
10+
stdout_logfile=/var/log/zulip/server.log
11+
stdout_logfile_maxbytes=50MB
12+
stdout_logfile_backups=10
13+
redirect_stderr=true
14+
autostart=true
15+
autorestart=true
16+
priority=10
17+
startsecs=10
18+
startretries=3
19+
20+
[program:cron]
21+
command=/usr/sbin/cron -f
22+
autostart=true
23+
autorestart=true

0 commit comments

Comments
 (0)