File tree Expand file tree Collapse file tree 2 files changed +44
-0
lines changed Expand file tree Collapse file tree 2 files changed +44
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Build smbmetrics
2
+ FROM docker.io/golang:1.17 as builder
3
+ ARG GIT_VERSION="(unset)"
4
+ ARG COMMIT_ID="(unset)"
5
+ ARG ARCH=""
6
+
7
+ WORKDIR /workspace
8
+ # Copy the Go Modules manifests
9
+ COPY go.mod go.mod
10
+ COPY go.sum go.sum
11
+ # cache deps before building and copying source so that we don't need to re-download as much
12
+ # and so that source changes don't invalidate our downloaded layer
13
+ RUN go mod download
14
+
15
+ # Copy the go source
16
+ COPY cmd cmd
17
+ COPY internal internal
18
+
19
+ # Build
20
+ RUN CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} GO111MODULE=on \
21
+ go build -a \
22
+ -ldflags "-X main.Version=${GIT_VERSION} -X main.CommitID=${COMMIT_ID}" \
23
+ -o smbmetrics cmd/main.go
24
+
25
+ # Use samba-server (with its smb.conf and samba utils) as base image
26
+ FROM quay.io/samba.org/samba-server
27
+ COPY --from=builder /workspace/smbmetrics /bin/smbmetrics
28
+
29
+ ENTRYPOINT ["/bin/smbmetrics" ]
30
+ EXPOSE 8080
Original file line number Diff line number Diff line change @@ -87,6 +87,20 @@ vet: reformat
87
87
yaml-fmt : yq
88
88
$(call yamls_reformat, $(CURDIR ) )
89
89
90
+ # Build the container image
91
+ .PHONY : image-build
92
+ image-build : Dockerfile
93
+ $(CONTAINER_CMD ) build \
94
+ --build-arg=GIT_VERSION=" $( GIT_VERSION) " \
95
+ --build-arg=COMMIT_ID=" $( COMMIT_ID) " \
96
+ --build-arg=ARCH=" $( GOARCH) " \
97
+ $(CONTAINER_BUILD_OPTS ) -f $< -t $(IMG )
98
+
99
+ # Push the container image
100
+ .PHONY : image-push
101
+ image-push :
102
+ $(CONTAINER_CMD ) push $(IMG )
103
+
90
104
# Check the code
91
105
.PHONY : check check-golangci-lint check-format check-yaml
92
106
You can’t perform that action at this time.
0 commit comments