-
Notifications
You must be signed in to change notification settings - Fork 8
/
Dockerfile
71 lines (60 loc) · 2.43 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
# Grab base Alpine
FROM alpine:3.17.1
LABEL author="atunnecliffe <andrew@atunnecliffe.com>"
# Set environment variables
ENV HOME /root
ENV SPLUNK_HOME /opt/splunk
ENV DEBIAN_FRONTEND noninteractive
ENV LC_ALL C.UTF-8
ENV LANG en_GB.UTF-8
ENV LANGUAGE en_GB.UTF-8
# ARGS
ARG DOWNLOAD_TARGET=https://download.splunk.com/products/splunk/releases/9.0.3/linux/splunk-9.0.3-dd0128b1f8cd-Linux-x86_64.tgz
ARG SPLUNK_CLI_ARGS="--accept-license --no-prompt"
ARG ADMIN_PASSWORD=changeme2019
ARG TZ=Etc/UTC
# ENVS based on ARGS (so you can configure either at build time or runtime)
ENV DOWNLOAD_TARGET $DOWNLOAD_TARGET
ENV SPLUNK_CLI_ARGS $SPLUNK_CLI_ARGS
ENV ADMIN_PASSWORD $ADMIN_PASSWORD
ENV TZ=$TZ
# Add Splunk to env
ENV PATH=${SPLUNK_HOME}/bin:${PATH} HOME=$SPLUNK_HOME
# Add indexed data dir
RUN mkdir -p /splunkdata
# Prepare startup script
WORKDIR ${SPLUNK_HOME}
COPY gosplunk.sh ./gosplunk.sh
RUN chmod +x ./gosplunk.sh
# Download Splunk and fix permissions
# Configure user nobody to match unRAID's settings
# Splunk expects users to have an entry in /etc/passwd, OpenShift doesn't generate this so we will create one.
# See additional code in entrypoint script for writing the file.
RUN FILE=`echo $DOWNLOAD_TARGET | sed -r 's/^.+(splunk-[^-]+).+$/\1/g'` && \
wget -q -O $SPLUNK_HOME/$FILE.tar.gz $DOWNLOAD_TARGET && \
chgrp -R 0 ${SPLUNK_HOME} && \
chmod -R g=u ${SPLUNK_HOME} && \
chmod -R 755 ${SPLUNK_HOME} && \
chgrp -R 0 /splunkdata && \
chmod -R g=u /splunkdata && \
chmod -R 755 /splunkdata && \
chmod -R g=u /etc/passwd
# Install dependancies
# wget: for downloading Splunk and dependancies
# tar: for installing Splunk
# alpine-sdk: provides linkers/builders required to run Splunk
# ca-certificates: required to securely download modified glibc
# procps: required as Splunk uses ps with non-busybox arguments
# tzdata: required to set timezone
RUN apk add --no-cache --virtual wget tar alpine-sdk ca-certificates procps tzdata
# Install custom glibc builder compatible with Splunk
RUN wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub && \
wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.29-r0/glibc-2.29-r0.apk && \
apk add glibc-2.29-r0.apk && \
rm -f glibc-2.29-r0.apk
# Set up ports and volumes
VOLUME ["/apps", "${SPLUNK_HOME}", "/splunkdata"]
EXPOSE 8000 8089 9997 8088 514
# Startup
WORKDIR ${SPLUNK_HOME}
ENTRYPOINT [ "./gosplunk.sh" ]