Skip to content

Commit f5b1c10

Browse files
committed
image: smbmetrics container image
Provide Dockerfile to dist smbmetrics executable as containerized image. Using samba-server with its smb.conf and samba utils as base image. Signed-off-by: Shachar Sharon <[email protected]>
1 parent 669587a commit f5b1c10

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

Dockerfile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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

Makefile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,20 @@ vet: reformat
8787
yaml-fmt: yq
8888
$(call yamls_reformat, $(CURDIR))
8989

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+
90104
# Check the code
91105
.PHONY: check check-golangci-lint check-format check-yaml
92106

0 commit comments

Comments
 (0)