Skip to content

Commit 543ba08

Browse files
andrewschoenbigjust
authored andcommitted
add downstream Dockerfile
and files needed for the container build Signed-off-by: Andrew Schoen <[email protected]>
1 parent ca4a3e6 commit 543ba08

File tree

3 files changed

+144
-0
lines changed

3 files changed

+144
-0
lines changed

Dockerfile

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Build stage 1
2+
3+
FROM openshift/golang-builder:rhel_9_golang_1.23 AS builder
4+
5+
COPY $REMOTE_SOURCE $REMOTE_SOURCE_DIR
6+
7+
WORKDIR $REMOTE_SOURCE_DIR/app
8+
9+
ENV GOFLAGS="-mod=vendor"
10+
11+
RUN go run -mod vendor build.go -dev build
12+
13+
# Build stage 2
14+
FROM registry.redhat.io/ubi9/ubi-minimal:latest
15+
16+
# Update the image to get the latest CVE updates
17+
RUN microdnf update -y
18+
19+
ENV PATH=/usr/share/grafana/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \
20+
GF_PATHS_CONFIG="/etc/grafana/grafana.ini" \
21+
GF_PATHS_DATA="/var/lib/grafana" \
22+
GF_PATHS_HOME="/usr/share/grafana" \
23+
GF_PATHS_LOGS="/var/log/grafana" \
24+
GF_PATHS_PLUGINS="/usr/share/grafana/plugins" \
25+
GF_PATHS_PROVISIONING="/etc/grafana/provisioning"
26+
27+
RUN rm -rf $GF_PATHS_HOME && mkdir -p $GF_PATHS_HOME
28+
COPY --from=builder $REMOTE_SOURCE_DIR/app/bin/grafana /usr/bin/grafana
29+
COPY --from=builder $REMOTE_SOURCE_DIR/app/bin/grafana-server /usr/bin/grafana-server
30+
COPY --from=builder $REMOTE_SOURCE_DIR/app/bin/grafana-cli /usr/bin/grafana-cli
31+
COPY --from=builder $REMOTE_SOURCE_DIR/app/conf $GF_PATHS_HOME/conf/
32+
COPY --from=builder $REMOTE_SOURCE_DIR/app/docs $GF_PATHS_HOME/docs/
33+
COPY --from=builder $REMOTE_SOURCE_DIR/app/public $GF_PATHS_HOME/public/
34+
COPY --from=builder $REMOTE_SOURCE_DIR/app/scripts $GF_PATHS_HOME/scripts/
35+
36+
RUN rm -rf /etc/grafana && mkdir -p /etc/grafana
37+
COPY --from=builder $REMOTE_SOURCE_DIR/app/conf/sample.ini $GF_PATHS_CONFIG
38+
COPY --from=builder $REMOTE_SOURCE_DIR/app/conf/ldap.toml /etc/grafana/ldap.toml
39+
COPY ./run.sh /run.sh
40+
41+
# Create grafana user/group
42+
RUN microdnf install -y shadow-utils
43+
RUN groupadd -r -g 472 grafana
44+
RUN useradd -r -u 472 -g grafana -d /etc/grafana -s /sbin/nologin -c "Grafana Dashboard" grafana
45+
46+
# Unpack plugins and update permissions
47+
RUN mkdir -p "$GF_PATHS_HOME/.aws" && \
48+
mkdir -p "$GF_PATHS_PROVISIONING/datasources" \
49+
"$GF_PATHS_PROVISIONING/dashboards" \
50+
"$GF_PATHS_PROVISIONING/notifiers" \
51+
"$GF_PATHS_PROVISIONING/plugins" \
52+
"$GF_PATHS_PROVISIONING/access-control" \
53+
"$GF_PATHS_PROVISIONING/alerting" \
54+
"$GF_PATHS_LOGS" \
55+
"$GF_PATHS_PLUGINS" \
56+
"$GF_PATHS_DATA" && \
57+
chown -R grafana:grafana "$GF_PATHS_DATA" "$GF_PATHS_HOME/.aws" "$GF_PATHS_LOGS" "$GF_PATHS_PLUGINS" "$GF_PATHS_PROVISIONING" && \
58+
chmod -R 775 "$GF_PATHS_DATA" "$GF_PATHS_HOME/.aws" "$GF_PATHS_LOGS" "$GF_PATHS_PLUGINS" "$GF_PATHS_PROVISIONING" /run.sh
59+
60+
EXPOSE 3000
61+
62+
USER grafana
63+
WORKDIR /
64+
ENTRYPOINT [ "/run.sh" ]
65+
66+
# Build specific labels
67+
LABEL maintainer="Nizamudeen A <[email protected]>"
68+
LABEL com.redhat.component="grafana-container"
69+
LABEL version=11.5.2
70+
LABEL name="grafana"
71+
LABEL description="Red Hat Ceph Storage Grafana container"
72+
LABEL summary="Grafana container on RHEL 9 for Red Hat Ceph Storage"
73+
LABEL io.k8s.display-name="Grafana on RHEL 9"
74+
LABEL io.openshift.tags="rhceph ceph dashboard grafana"

ceph-dashboard.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
apiVersion: 1
2+
providers:
3+
- name: 'Ceph Dashboard'
4+
torgId: 1
5+
folder: 'ceph-dashboard'
6+
type: file
7+
disableDeletion: false
8+
updateIntervalSeconds: 3
9+
editable: false
10+
options:
11+
path: '/etc/grafana/dashboards/ceph-dashboard'

run.sh

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/bin/bash -e
2+
3+
PERMISSIONS_OK=0
4+
5+
if [ ! -r "$GF_PATHS_CONFIG" ]; then
6+
echo "GF_PATHS_CONFIG='$GF_PATHS_CONFIG' is not readable."
7+
PERMISSIONS_OK=1
8+
fi
9+
10+
if [ ! -w "$GF_PATHS_DATA" ]; then
11+
echo "GF_PATHS_DATA='$GF_PATHS_DATA' is not writable."
12+
PERMISSIONS_OK=1
13+
fi
14+
15+
if [ ! -r "$GF_PATHS_HOME" ]; then
16+
echo "GF_PATHS_HOME='$GF_PATHS_HOME' is not readable."
17+
PERMISSIONS_OK=1
18+
fi
19+
20+
if [ $PERMISSIONS_OK -eq 1 ]; then
21+
echo "You may have issues with file permissions, more information here: http://docs.grafana.org/installation/docker/#migration-from-a-previous-version-of-the-docker-container-to-5-1-or-later"
22+
fi
23+
24+
if [ ! -d "$GF_PATHS_PLUGINS" ]; then
25+
mkdir "$GF_PATHS_PLUGINS"
26+
fi
27+
28+
if [ ! -z ${GF_AWS_PROFILES+x} ]; then
29+
> "$GF_PATHS_HOME/.aws/credentials"
30+
31+
for profile in ${GF_AWS_PROFILES}; do
32+
access_key_varname="GF_AWS_${profile}_ACCESS_KEY_ID"
33+
secret_key_varname="GF_AWS_${profile}_SECRET_ACCESS_KEY"
34+
region_varname="GF_AWS_${profile}_REGION"
35+
36+
if [ ! -z "${!access_key_varname}" -a ! -z "${!secret_key_varname}" ]; then
37+
echo "[${profile}]" >> "$GF_PATHS_HOME/.aws/credentials"
38+
echo "aws_access_key_id = ${!access_key_varname}" >> "$GF_PATHS_HOME/.aws/credentials"
39+
echo "aws_secret_access_key = ${!secret_key_varname}" >> "$GF_PATHS_HOME/.aws/credentials"
40+
if [ ! -z "${!region_varname}" ]; then
41+
echo "region = ${!region_varname}" >> "$GF_PATHS_HOME/.aws/credentials"
42+
fi
43+
fi
44+
done
45+
46+
chmod 600 "$GF_PATHS_HOME/.aws/credentials"
47+
fi
48+
49+
export HOME="$GF_PATHS_HOME"
50+
51+
exec grafana server \
52+
--homepath="$GF_PATHS_HOME" \
53+
--config="$GF_PATHS_CONFIG" \
54+
"$@" \
55+
cfg:default.log.mode="console" \
56+
cfg:default.paths.data="$GF_PATHS_DATA" \
57+
cfg:default.paths.logs="$GF_PATHS_LOGS" \
58+
cfg:default.paths.plugins="$GF_PATHS_PLUGINS" \
59+
cfg:default.paths.provisioning="$GF_PATHS_PROVISIONING"

0 commit comments

Comments
 (0)