forked from blacklabelops/logrotate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
59 lines (54 loc) · 1.72 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
FROM alpine
LABEL MAINTAINER="Greg White <[email protected]>"
# logrotate version (e.g. 3.9.1-r0)
ARG LOGROTATE_VERSION=latest
# permissions
ARG CONTAINER_UID=1000
ARG CONTAINER_GID=1000
ENV GOPATH /usr/bin
# install dev tools
RUN export CONTAINER_USER=logrotate && \
export CONTAINER_GROUP=logrotate && \
addgroup -g $CONTAINER_GID logrotate && \
adduser -u $CONTAINER_UID -G logrotate -h /usr/bin/logrotate.d -s /bin/bash -S logrotate && \
apk add --update && \
apk add --virtual build-dependencies \
go gcc g++ wget git tar gzip && \
apk add \
bash \
tini \
tzdata && \
if [ "${LOGROTATE_VERSION}" = "latest" ]; \
then apk add logrotate ; \
else apk add "logrotate=${LOGROTATE_VERSION}" ; \
fi && \
mkdir -p /usr/bin/logrotate.d && \
cd ${GOPATH} && \
mkdir -p src/github.com/odise/ && \
cd src/github.com/odise && \
git clone https://github.com/odise/go-cron.git && \
cd go-cron && \
go get -d && \
go build -o /usr/bin/go-cron -ldflags "-X main.build=`git rev-parse --short HEAD`" bin/go-cron.go && \
apk del build-dependencies && \
rm -rf /var/cache/apk/* && \
rm -rf ${GOPATH}/src && \
rm -rf /tmp/*
# environment variable for this container
ENV LOGROTATE_OLDDIR= \
LOGROTATE_COMPRESSION= \
LOGROTATE_INTERVAL= \
LOGROTATE_COPIES= \
LOGROTATE_SIZE= \
LOGS_DIRECTORIES= \
LOG_FILE_ENDINGS= \
LOGROTATE_LOGFILE= \
LOGROTATE_CRONSCHEDULE= \
LOGROTATE_PARAMETERS= \
LOGROTATE_STATUSFILE= \
LOG_FILE=
COPY *.sh /usr/bin/logrotate.d/
RUN chmod 755 /usr/bin/logrotate.d/*.sh
ENTRYPOINT ["/sbin/tini","--","/usr/bin/logrotate.d/docker-entrypoint.sh"]
VOLUME ["/logrotate-status"]
CMD ["cron"]