2020-04-24 07:03:18 -05:00
|
|
|
ARG BASE_IMAGE=ubuntu:20.04
|
2019-11-07 09:36:40 -06:00
|
|
|
FROM ${BASE_IMAGE} AS grafana-builder
|
|
|
|
|
|
|
|
ARG GRAFANA_TGZ="grafana-latest.linux-x64.tar.gz"
|
|
|
|
|
|
|
|
COPY ${GRAFANA_TGZ} /tmp/grafana.tar.gz
|
|
|
|
|
2020-09-29 14:34:34 -05:00
|
|
|
RUN mkdir /tmp/grafana && tar xzf /tmp/grafana.tar.gz --strip-components=1 -C /tmp/grafana
|
2019-11-07 09:36:40 -06:00
|
|
|
|
|
|
|
FROM ${BASE_IMAGE}
|
|
|
|
|
|
|
|
EXPOSE 3000
|
|
|
|
|
|
|
|
# Set DEBIAN_FRONTEND=noninteractive in environment at build-time
|
|
|
|
ARG DEBIAN_FRONTEND=noninteractive
|
|
|
|
ARG GF_UID="472"
|
2020-10-14 06:38:04 -05:00
|
|
|
ARG GF_GID="0"
|
2019-11-07 09:36:40 -06:00
|
|
|
|
|
|
|
ENV PATH=/usr/share/grafana/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \
|
|
|
|
GF_PATHS_CONFIG="/etc/grafana/grafana.ini" \
|
|
|
|
GF_PATHS_DATA="/var/lib/grafana" \
|
|
|
|
GF_PATHS_HOME="/usr/share/grafana" \
|
|
|
|
GF_PATHS_LOGS="/var/log/grafana" \
|
|
|
|
GF_PATHS_PLUGINS="/var/lib/grafana/plugins" \
|
|
|
|
GF_PATHS_PROVISIONING="/etc/grafana/provisioning"
|
|
|
|
|
|
|
|
WORKDIR $GF_PATHS_HOME
|
|
|
|
|
|
|
|
# Install dependencies
|
2020-04-15 15:17:41 -05:00
|
|
|
# We need curl in the image
|
2020-07-28 10:07:23 -05:00
|
|
|
RUN apt-get update && apt-get install -y ca-certificates curl tzdata && \
|
2020-04-15 15:17:41 -05:00
|
|
|
apt-get autoremove -y && rm -rf /var/lib/apt/lists/*;
|
2019-11-07 09:36:40 -06:00
|
|
|
|
|
|
|
COPY --from=grafana-builder /tmp/grafana "$GF_PATHS_HOME"
|
|
|
|
|
2020-10-14 06:38:04 -05:00
|
|
|
RUN if [ ! $(getent group "$GF_GID") ]; then \
|
|
|
|
addgroup --system --gid $GF_GID grafana; \
|
|
|
|
fi
|
|
|
|
|
|
|
|
RUN export GF_GID_NAME=$(getent group $GF_GID | cut -d':' -f1) && \
|
|
|
|
mkdir -p "$GF_PATHS_HOME/.aws" && \
|
|
|
|
adduser --system --uid $GF_UID --ingroup "$GF_GID_NAME" grafana && \
|
2019-11-07 09:36:40 -06:00
|
|
|
mkdir -p "$GF_PATHS_PROVISIONING/datasources" \
|
|
|
|
"$GF_PATHS_PROVISIONING/dashboards" \
|
|
|
|
"$GF_PATHS_PROVISIONING/notifiers" \
|
2020-07-02 08:43:12 -05:00
|
|
|
"$GF_PATHS_PROVISIONING/plugins" \
|
2021-05-20 02:41:39 -05:00
|
|
|
"$GF_PATHS_PROVISIONING/access-control" \
|
2019-11-07 09:36:40 -06:00
|
|
|
"$GF_PATHS_LOGS" \
|
|
|
|
"$GF_PATHS_PLUGINS" \
|
|
|
|
"$GF_PATHS_DATA" && \
|
|
|
|
cp "$GF_PATHS_HOME/conf/sample.ini" "$GF_PATHS_CONFIG" && \
|
|
|
|
cp "$GF_PATHS_HOME/conf/ldap.toml" /etc/grafana/ldap.toml && \
|
2020-10-14 06:38:04 -05:00
|
|
|
chown -R "grafana:$GF_GID_NAME" "$GF_PATHS_DATA" "$GF_PATHS_HOME/.aws" "$GF_PATHS_LOGS" "$GF_PATHS_PLUGINS" "$GF_PATHS_PROVISIONING" && \
|
2019-11-07 09:36:40 -06:00
|
|
|
chmod -R 777 "$GF_PATHS_DATA" "$GF_PATHS_HOME/.aws" "$GF_PATHS_LOGS" "$GF_PATHS_PLUGINS" "$GF_PATHS_PROVISIONING"
|
|
|
|
|
|
|
|
COPY ./run.sh /run.sh
|
|
|
|
|
2020-10-14 06:38:04 -05:00
|
|
|
USER "$GF_UID"
|
2019-11-07 09:36:40 -06:00
|
|
|
ENTRYPOINT [ "/run.sh" ]
|