forked from grafana/grafana
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathContainerfile.operator
83 lines (66 loc) · 3.13 KB
/
Containerfile.operator
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
# Copyright Contributors to the Open Cluster Management project
# Licensed under the Apache License 2.0
FROM brew.registry.redhat.io/rh-osbs/openshift-golang-builder:rhel_9_1.21 AS builder
WORKDIR $GOPATH/src/github.com/grafana/grafana
ENV GOFLAGS="-mod=mod"
COPY .git/ ./.git/
COPY go.mod go.sum embed.go Makefile build.go package.json ./
COPY cue cue/
COPY packages/grafana-schema packages/grafana-schema/
COPY public/app/plugins public/app/plugins/
COPY pkg pkg/
COPY scripts scripts/
COPY cue.mod cue.mod/
COPY .bingo .bingo
RUN make gen-go
RUN go mod verify
RUN GOFLAGS="" go run build.go build
# Need to copy the generated binaries to a non-platform specific location to handle
# s390x builds for example
RUN cp $GOPATH/src/github.com/grafana/grafana/bin/linux-$(go env GOARCH)/grafana-server \
$GOPATH/src/github.com/grafana/grafana/bin/linux-$(go env GOARCH)/grafana-cli \
/usr/bin/
# Final container
FROM registry.access.redhat.com/ubi9/ubi:latest
LABEL io.k8s.display-name="Grafana" \
io.k8s.description="Grafana is an open-source, general purpose dashboard and graph composer" \
io.openshift.tags="openshift" \
summary="Grafana is an open-source, general purpose dashboard and graph composer" \
maintainer="Red Hat Advanced Cluster Management for Kubernetes <[email protected]>"
ARG GF_UID="472"
ARG GF_GID="472"
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
COPY conf ./conf
RUN yum update -y && \
yum clean all && \
mkdir -p "$GF_PATHS_HOME/.aws" && \
# addgroup -S -g $GF_GID grafana && \
# adduser -S -u $GF_UID -G grafana grafana && \
# Note: the openshift base image does not include the addgroup and adduser commands so we have to use useradd/groupadd
groupadd --system -g $GF_GID grafana && \
useradd --system -u $GF_UID -g grafana grafana && \
mkdir -p "$GF_PATHS_PROVISIONING/datasources" \
"$GF_PATHS_PROVISIONING/dashboards" \
"$GF_PATHS_PROVISIONING/notifiers" \
"$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 && \
chown -R grafana:grafana "$GF_PATHS_DATA" "$GF_PATHS_HOME/.aws" "$GF_PATHS_LOGS" "$GF_PATHS_PLUGINS" "$GF_PATHS_PROVISIONING" && \
chmod -R 777 "$GF_PATHS_DATA" "$GF_PATHS_HOME/.aws" "$GF_PATHS_LOGS" "$GF_PATHS_PLUGINS" "$GF_PATHS_PROVISIONING"
# Note: the openshift build requires a name to reference the build container in the '--from' option instead of using the index '0' as is done upstream
COPY --from=builder /usr/bin/grafana-server /usr/bin/grafana-cli ./bin/
COPY public ./public
COPY tools ./tools
EXPOSE 3000
COPY ./packaging/docker/run.sh /run.sh
USER grafana
ENTRYPOINT [ "/run.sh" ]