Skip to content

Commit

Permalink
Build go binary in Docker
Browse files Browse the repository at this point in the history
  • Loading branch information
v-zhuravlev committed Jun 24, 2022
1 parent 2aa7f66 commit 1427913
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.*
Dockerfile
LICENSE*
NOTICE*
README*
iperf3_windows.go
20 changes: 15 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
FROM golang:alpine AS build-env

# Download dependencies
WORKDIR /go/src
COPY go.mod go.sum ./
RUN go mod download

# Build current sources
COPY . .
RUN go build -o /go/bin/iperf3_exporter

# Prepare runtime environment
FROM alpine:latest
LABEL maintainer="Edgard Castro <[email protected]>"

EXPOSE 9579
RUN apk add --no-cache iperf3
COPY iperf3_exporter /bin/iperf3_exporter

ENTRYPOINT ["/bin/iperf3_exporter"]
EXPOSE 9579
COPY --from=build-env /go/bin/iperf3_exporter /bin/
ENTRYPOINT ["/bin/iperf3_exporter"]

0 comments on commit 1427913

Please sign in to comment.