forked from kloudsense/cloudera_exporter
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDockerfile
67 lines (51 loc) · 1.51 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
####################
## STEP 1: Build ##
####################
# Image Base
FROM golang:1.12 AS builder
# Labels
LABEL maintainer="Keedio Sistemas <[email protected]>"
LABEL version="1.3"
LABEL description="Keedio Cloudera Exporter Builder"
LABEL vendor="keedio"
LABEL image_name="cloudera_exporter_builder"
# System Configs
WORKDIR /go
# Code Folder
RUN mkdir cloudera_exporter_code
# Workdir with the cloudera_exporter's code
WORKDIR /go/cloudera_exporter_code
# Add cloudera_exporter's code
COPY ./collector ./collector
COPY ./config_parser ./config_parser
COPY ./json_parser ./json_parser
COPY ./logger ./logger
COPY ./cloudera_exporter.go ./cloudera_exporter.go
COPY ./config.ini ./config.ini
RUN go mod init keedio/cloudera_exporter
# Environment variable to Static-link compilation
ENV CGO_ENABLED 0
# Work Go Path
ENV GOPATH /go
# GO OS system for compatibility compilation
ENV GOOS linux
# GO OS system architecture
ENV GOARCH amd64
# Run command
RUN go build -o cloudera_exporter cloudera_exporter.go
####################
## STEP 2: Run ##
####################
FROM scratch
# Labels
LABEL maintainer="Keedio Sistemas <[email protected]>"
LABEL version="1.3"
LABEL description="Keedio Cloudera Exporter"
LABEL vendor="keedio"
LABEL image_name="cloudera_exporter"
# Binary
COPY --from=builder /go/cloudera_exporter_code/cloudera_exporter /cloudera_exporter
# Config File
COPY --from=builder /go/cloudera_exporter_code/config.ini /config.ini
EXPOSE 9200
ENTRYPOINT ["/cloudera_exporter", "--config-file", "/config.ini"]