Skip to content

Commit

Permalink
Merge pull request #5 from Squtis1/master
Browse files Browse the repository at this point in the history
Adding logrotate
  • Loading branch information
pgesek authored Jul 21, 2023
2 parents 64a2084 + 0acc7e5 commit b893667
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
14 changes: 13 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,30 @@
FROM nginx:1.12-alpine
FROM nginx:1.24.0-alpine

RUN apk --no-cache add openssl

# Add logrotate
RUN apk --no-cache add logrotate

# Download and install consul-template
RUN wget -O /home/consul-template.zip \
https://releases.hashicorp.com/consul-template/0.16.0/consul-template_0.16.0_linux_386.zip && \
unzip /home/consul-template.zip -d /usr/bin && \
chmod +x /usr/bin/consul-template && \
rm /home/consul-template.zip && \
mkdir /var/log/consul-template

# Copy over configuration files and scripts
COPY nginx.conf /etc/nginx/nginx.conf
COPY openlmis.conf /etc/consul-template/openlmis.conf
COPY run.sh /home/run.sh

# Add a logrotate configuration file for nginx and consul-template
COPY logrotate.conf /etc/logrotate.d/nginx

# Change permissions for logrotate.conf
RUN chmod 644 /etc/logrotate.d/nginx

# Set volumes for log files
VOLUME [ "/var/log/nginx", "/var/log/consul-template" ]

ENTRYPOINT [ "/home/run.sh" ]
8 changes: 8 additions & 0 deletions logrotate.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/var/log/nginx/log/*.log /var/log/consul-template/*.log {
daily
rotate 7
compress
missingok
notifempty
create 0660 root root
}

0 comments on commit b893667

Please sign in to comment.