File tree 3 files changed +40
-14
lines changed
3 files changed +40
-14
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 5
5
FROM node:lts-alpine
6
6
7
7
# Install system dependencies
8
- RUN apk add --no-cache logrotate openssl supercronic tzdata
8
+ RUN apk add --no-cache openssl supercronic tzdata
9
9
10
10
# Set the working directory to the website files
11
11
WORKDIR /usr/src/app
@@ -29,7 +29,7 @@ RUN --mount=type=cache,target=.npm \
29
29
RUN npx tsc --skipLibCheck scripts/create-fake-accounts.ts scripts/expired-files.ts scripts/outdated-notifications.ts && \
30
30
echo "*/5 * * * * node /usr/src/app/scripts/expired-files.js > /dev/null 2>&1" >> /var/spool/cron/crontabs/node && \
31
31
echo "*/5 * * * * node /usr/src/app/scripts/outdated-notifications > /dev/null 2>&1" >> /var/spool/cron/crontabs/node && \
32
- echo "0 0 * * * logrotate -f /usr/src/app/docker/configuration /logrotate.conf -s /usr/src/app/docker/configuration/logrotate.status > /dev/null 2>&1" >> /var/spool/cron/crontabs/node
32
+ echo "0 0 * * * /usr/src/app/docker/scripts /logrotate.sh > /dev/null 2>&1" >> /var/spool/cron/crontabs/node
33
33
34
34
# Add wait script to wait for other services to be ready
35
35
ADD --chmod=0755 https://github.com/ufoscout/docker-compose-wait/releases/latest/download/wait /wait
@@ -39,5 +39,4 @@ USER node
39
39
40
40
# Prepare project files and configuration to be built
41
41
RUN npm run build && npm prune --production && \
42
- chmod +x ./docker/scripts/entrypoint.sh && \
43
- chmod 644 /usr/src/app/docker/configuration/logrotate.conf
42
+ chmod +x ./docker/scripts/entrypoint.sh ./docker/scripts/logrotate.sh
Original file line number Diff line number Diff line change
1
+ #! /bin/sh
2
+
3
+ echo " Copying application.log to $( date +" %Y-%m-%d" ) .log..."
4
+
5
+ # Go to logs directory
6
+ cd logs
7
+
8
+ # Copy content from source file to dated log file
9
+ cp " application.log" " $( date +" %Y-%m-%d" ) .log"
10
+
11
+ # Clear the content of the source file
12
+ > " application.log"
13
+ echo " Source log has been cleared."
14
+
15
+ # Get list of .log files, excluding application.log
16
+ LOG_FILES=$( ls -1 * .log 2> /dev/null | grep -v " ^application.log$" )
17
+
18
+ # Count number of log files
19
+ LOG_COUNT=$( echo " $LOG_FILES " | wc -l)
20
+
21
+ echo " $LOG_COUNT log files found."
22
+
23
+ # Keep only the 14 newest by filename (sorted alphabetically, oldest first)
24
+ if [ " $LOG_COUNT " -gt 14 ]; then
25
+ FILES_TO_DELETE=$( echo " $LOG_FILES " | sort | head -n $(( $LOG_COUNT - 14 )) )
26
+
27
+ echo " Deleting old log files:"
28
+
29
+ for file in $FILES_TO_DELETE ; do
30
+ echo " - Deleting $file "
31
+ rm -f " $file "
32
+ done
33
+ else
34
+ echo " No log files to delete. Keeping all $LOG_COUNT files."
35
+ fi
36
+
37
+ echo " Done."
You can’t perform that action at this time.
0 commit comments