forked from Graylog2/graylog-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
149 lines (130 loc) · 4.84 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
# -------------------------------------------------------------------------------------------------
#
# layer for download and verifying
FROM debian:stretch-slim as graylog-downloader
ARG VCS_REF
ARG GRAYLOG_VERSION
WORKDIR /tmp
# hadolint ignore=DL3008,DL3009,DL3014,DL3015
RUN \
apt-get update > /dev/null && \
apt-get install --assume-yes \
ca-certificates \
curl > /dev/null
RUN \
curl \
--silent \
--location \
--retry 3 \
--output "/tmp/graylog-${GRAYLOG_VERSION}.tgz" \
"https://packages.graylog2.org/releases/graylog/graylog-${GRAYLOG_VERSION}.tgz"
RUN \
curl \
--silent \
--location \
--retry 3 \
--output "/tmp/graylog-${GRAYLOG_VERSION}.tgz.sha256.txt" \
"https://packages.graylog2.org/releases/graylog/graylog-${GRAYLOG_VERSION}.tgz.sha256.txt"
RUN \
sha256sum --check "graylog-${GRAYLOG_VERSION}.tgz.sha256.txt"
RUN \
mkdir /opt/graylog && \
tar --extract --gzip --file "/tmp/graylog-${GRAYLOG_VERSION}.tgz" --strip-components=1 --directory /opt/graylog
RUN \
install \
--directory \
--mode=0750 \
/opt/graylog/data \
/opt/graylog/data/journal \
/opt/graylog/data/log \
/opt/graylog/data/config \
/opt/graylog/data/plugin \
/opt/graylog/data/data
# -------------------------------------------------------------------------------------------------
#
# final layer
# use the smallest debain with headless openjdk and copying files from download layers
FROM openjdk:8-jre-slim
ARG VCS_REF
ARG GRAYLOG_VERSION
ARG BUILD_DATE
ARG GRAYLOG_HOME=/usr/share/graylog
ARG GRAYLOG_USER=graylog
ARG GRAYLOG_UID=1100
ARG GRAYLOG_GROUP=graylog
ARG GRAYLOG_GID=1100
# hadolint ignore=DL3023
COPY --from=graylog-downloader /opt/graylog ${GRAYLOG_HOME}
COPY config ${GRAYLOG_HOME}/data/config
WORKDIR ${GRAYLOG_HOME}
# hadolint ignore=DL3008,DL3014,SC2086
RUN \
echo "export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/jre" > /etc/profile.d/graylog.sh && \
echo "export BUILD_DATE=${BUILD_DATE}" >> /etc/profile.d/graylog.sh && \
echo "export GRAYLOG_VERSION=${GRAYLOG_VERSION}" >> /etc/profile.d/graylog.sh && \
echo "export GRAYLOG_SERVER_JAVA_OPTS='-XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap -XX:NewRatio=1 -XX:MaxMetaspaceSize=256m -server -XX:+ResizeTLAB -XX:+UseConcMarkSweepGC -XX:+CMSConcurrentMTEnabled -XX:+CMSClassUnloadingEnabled -XX:+UseParNewGC -XX:-OmitStackTraceInFastThrow'" >> /etc/profile.d/graylog.sh && \
echo "export GRAYLOG_HOME=${GRAYLOG_HOME}" >> /etc/profile.d/graylog.sh && \
echo "export GRAYLOG_USER=${GRAYLOG_USER}" >> /etc/profile.d/graylog.sh && \
echo "export GRAYLOG_GROUP=${GRAYLOG_GROUP}" >> /etc/profile.d/graylog.sh && \
echo "export GRAYLOG_UID=${GRAYLOG_UID}" >> /etc/profile.d/graylog.sh && \
echo "export GRAYLOG_GID=${GRAYLOG_GID}" >> /etc/profile.d/graylog.sh && \
echo "export PATH=${GRAYLOG_HOME}/bin:${PATH}" >> /etc/profile.d/graylog.sh && \
apt-get update > /dev/null && \
apt-get install --no-install-recommends --assume-yes \
curl \
libcap2-bin \
libglib2.0-0 \
fontconfig > /dev/null && \
addgroup \
--gid "${GRAYLOG_GID}" \
--quiet \
"${GRAYLOG_GROUP}" && \
adduser \
--disabled-password \
--disabled-login \
--gecos '' \
--home ${GRAYLOG_HOME} \
--uid "${GRAYLOG_UID}" \
--gid "${GRAYLOG_GID}" \
--quiet \
"${GRAYLOG_USER}" && \
chown --recursive "${GRAYLOG_USER}":"${GRAYLOG_GROUP}" ${GRAYLOG_HOME} && \
setcap 'cap_net_bind_service=+ep' "${JAVA_HOME}/bin/java" && \
apt-get remove --assume-yes --purge \
apt-utils > /dev/null && \
rm -f /etc/apt/sources.list.d/* && \
apt-get clean > /dev/null && \
apt autoremove --assume-yes > /dev/null && \
rm -rf \
/tmp/* \
/var/cache/debconf/* \
/var/lib/apt/lists/* \
/var/log/* \
/usr/share/X11 \
/usr/share/doc/* 2> /dev/null
COPY docker-entrypoint.sh /
COPY health_check.sh /
EXPOSE 9000
USER ${GRAYLOG_USER}
VOLUME ${GRAYLOG_HOME}/data
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["graylog"]
# add healthcheck
HEALTHCHECK \
--interval=10s \
--timeout=2s \
--retries=12 \
CMD /health_check.sh
# -------------------------------------------------------------------------------------------------
LABEL maintainer="Graylog, Inc. <[email protected]>" \
org.label-schema.name="Graylog Docker Image" \
org.label-schema.description="Official Graylog Docker image" \
org.label-schema.url="https://www.graylog.org/" \
org.label-schema.vcs-ref=${VCS_REF} \
org.label-schema.vcs-url="https://github.com/Graylog2/graylog-docker" \
org.label-schema.vendor="Graylog, Inc." \
org.label-schema.version=${GRAYLOG_VERSION} \
org.label-schema.schema-version="1.0" \
org.label-schema.build-date=${BUILD_DATE} \
com.microscaling.docker.dockerfile="/Dockerfile" \
com.microscaling.license="Apache 2.0"