forked from grafana/grafana-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
42 lines (29 loc) · 1.24 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
FROM golang:1.13.3-alpine as go-builder
RUN apk add --no-cache ca-certificates git mercurial
ARG PROJECT_NAME=grafana-operator
ARG REPO_PATH=github.com/ucloud/$PROJECT_NAME
ARG BUILD_PATH=cmd/manager/main.go
WORKDIR /src
COPY go.mod go.sum ./
RUN go mod download
COPY pkg ./ cmd ./ version ./
# Build version and commit should be passed in when performing docker build
ARG VERSION=0.1.1
ARG GIT_SHA=0000000
RUN GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o ${GOBIN}/${PROJECT_NAME} \
-ldflags "-X ${REPO_PATH}/version.Version=${VERSION} -X ${REPO_PATH}/version.GitSHA=${GIT_SHA}" \
$BUILD_PATH
# =============================================================================
FROM alpine:3.9 AS final
ARG PROJECT_NAME=grafana-operator
ARG GRAFONNET_VERSION=0.1.0
RUN apk --no-cache add curl \
&& mkdir -p /tmp/graf \
&& mkdir -p /opt/jsonnet \
&& curl -SL https://github.com/grafana/grafonnet-lib/archive/v${GRAFONNET_VERSION}.tar.gz \
| tar -xzC /tmp/graf \
&& cp -r /tmp/graf/grafonnet-lib-${GRAFONNET_VERSION}/grafonnet /opt/jsonnet/grafonnet
COPY --from=go-builder ${GOBIN}/${PROJECT_NAME} /usr/local/bin/${PROJECT_NAME}
RUN adduser -D ${PROJECT_NAME}
USER ${PROJECT_NAME}
ENTRYPOINT ["/usr/local/bin/grafana-operator"]