-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
208 lines (139 loc) · 4.98 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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
FROM alpine:latest as builder
ARG http_proxy=http://xxxxxxxxxx:8080
ARG https_proxy=http://xxxxxxxxxx:9443
ARG no_proxy=localhost,127.0.0.1,.xxxxxxxxxx,.xxxxxxxxxx,.xxxxxxxxxx,.xxxxxxxxxx.com,.xxxxxxxxxx.com
ARG node_heap=12228
ARG corp_cert=your-cert.crt
USER root
WORKDIR /root
ENV HTTP_PROXY $http_proxy
ENV HTTPS_PROXY $https_proxy
ENV http_proxy $http_proxy
ENV https_proxy $https_proxy
ENV NO_PROXY $no_proxy
ENV no_proxy $no_proxy
ENV YARN_HTTP_PROXY $http_proxy
ENV YARN_HTTPS_PROXY $https_proxy
ENV NODE_OPTIONS --max-old-space-size=${node_heap}
COPY patch01 /root/patch01
COPY patch02 /root/patch02
COPY patch03 /root/patch03
COPY patch04 /root/patch04
COPY patch05 /root/patch05
COPY patch06 /root/patch06
COPY ${corp_cert} /tmp/cert
RUN cat /tmp/cert >> /etc/ssl/certs/ca-certificates.crt
RUN apk --no-cache add ca-certificates \
&& rm -rf /var/cache/apk/*
COPY ${corp_cert} /usr/local/share/ca-certificates
RUN update-ca-certificates
RUN apk update
RUN apk upgrade
RUN apk --no-cache add bash \
&& rm -rf /var/cache/apk/*
RUN apk --no-cache add nodejs \
&& rm -rf /var/cache/apk/*
RUN apk --no-cache add npm \
&& rm -rf /var/cache/apk/*
RUN apk --no-cache add yarn \
&& rm -rf /var/cache/apk/*
RUN apk --no-cache add git \
&& rm -rf /var/cache/apk/*
RUN apk --no-cache add go \
&& rm -rf /var/cache/apk/*
RUN apk --no-cache add vim \
&& rm -rf /var/cache/apk/*
RUN apk --no-cache add make \
&& rm -rf /var/cache/apk/*
RUN apk --no-cache add patch \
&& rm -rf /var/cache/apk/*
RUN yarn config set proxy $http_proxy
RUN yarn config set https-proxy $https_proxy
RUN npm config set proxy $http_proxy
RUN npm config set https-proxy $https_proxy
RUN git config --global http.proxy $http_proxy
RUN git config --global https.proxy $https_proxy
WORKDIR /root
RUN yarn set version 4.0.0-rc.12
RUN cp .yarn/releases/yarn-4.0.0-rc.12.cjs .
RUN rm -rf .yarn
RUN rm .yarn*
RUN rm package.json
RUN git clone https://github.com/grafana/grafana.git
WORKDIR /root/grafana
RUN git checkout tags/v9.0.5
RUN cp ../yarn-4.0.0-rc.12.cjs .yarn/releases/
RUN patch .yarnrc.yml ../patch01
RUN patch package.json ../patch02
RUN patch packages/grafana-data/package.json ../patch03
RUN patch packages/grafana-schema/package.json ../patch04
RUN patch packages/grafana-ui/package.json ../patch05
RUN patch scripts/cli/tsconfig.json ../patch06
RUN env
RUN yarn install
ENV NODE_ENV production
RUN yarn build
RUN go mod verify
RUN make build-go
# Final stage
FROM alpine:latest as grafana
ARG http_proxy=http://xxxxxxxxxx:8080
ARG https_proxy=http://xxxxxxxxxx:9443
ARG no_proxy=localhost,127.0.0.1,.xxxxxxxxxx,.xxxxxxxxxx,.xxxxxxxxxx,.xxxxxxxxxx.com,.xxxxxxxxxx.com
ARG corp_cert=your-cert.crt
ENV HTTP_PROXY $http_proxy
ENV HTTPS_PROXY $https_proxy
ENV http_proxy $http_proxy
ENV https_proxy $https_proxy
ENV NO_PROXY $no_proxy
ENV no_proxy $no_proxy
COPY ${corp_cert} /tmp/cert
RUN cat /tmp/cert >> /etc/ssl/certs/ca-certificates.crt
RUN apk --no-cache add ca-certificates \
&& rm -rf /var/cache/apk/*
COPY ${corp_cert} /usr/local/share/ca-certificates
RUN update-ca-certificates
RUN apk update
RUN apk upgrade
LABEL maintainer="You <[email protected]>"
ARG GF_UID="472"
ARG GF_GID="0"
ENV PATH="/usr/share/grafana/bin:$PATH" \
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
RUN apk add --no-cache ca-certificates bash tzdata musl-utils
RUN apk add --no-cache openssl ncurses-libs ncurses-terminfo-base
RUN apk upgrade ncurses-libs ncurses-terminfo-base
RUN apk info -vv | sort
COPY --from=builder /root/grafana/conf ./conf
RUN if [ ! $(getent group "$GF_GID") ]; then \
addgroup -S -g $GF_GID grafana; \
fi
RUN export GF_GID_NAME=$(getent group $GF_GID | cut -d':' -f1) && \
mkdir -p "$GF_PATHS_HOME/.aws" && \
adduser -S -u $GF_UID -G "$GF_GID_NAME" grafana && \
mkdir -p "$GF_PATHS_PROVISIONING/datasources" \
"$GF_PATHS_PROVISIONING/dashboards" \
"$GF_PATHS_PROVISIONING/notifiers" \
"$GF_PATHS_PROVISIONING/plugins" \
"$GF_PATHS_PROVISIONING/access-control" \
"$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:$GF_GID_NAME" "$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"
COPY --from=builder /root/grafana/bin/*/grafana-server /grafana/bin/*/grafana-cli ./bin/
COPY --from=builder /root/grafana/public ./public
COPY --from=builder /root/grafana/tools ./tools
EXPOSE 3000
COPY --from=builder /root/grafana/packaging/docker/run.sh /run.sh
USER grafana
ENTRYPOINT [ "/run.sh" ]
#CMD /bin/bash