Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add build target to Makefile & builder to Dockerfile #215

Merged
merged 1 commit into from
Mar 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,29 @@
FROM alpine:3.15.0
# Build the binary
FROM docker.io/library/golang:1.18 as builder

WORKDIR /workspace
# Copy the Go Modules manifests
COPY go.mod go.mod
COPY go.sum go.sum
# cache deps before building and copying source so that we don't need to re-download as much
# and so that source changes don't invalidate our downloaded layer
RUN go mod download

# Copy the go source
COPY main.go main.go
COPY cmd/ cmd/
COPY phpfpm/ phpfpm/

# Build
RUN CGO_ENABLED=0 go build -a -o php-fpm_exporter main.go

FROM docker.io/library/alpine:3.15.0

ARG BUILD_DATE
ARG VCS_REF
ARG VERSION

COPY php-fpm_exporter /
COPY --from=builder /workspace/php-fpm_exporter .

EXPOSE 9253
ENTRYPOINT [ "/php-fpm_exporter", "server" ]
Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ help: ## List targets & descriptions
deps: ## Get dependencies
go get -d -v ./...

build: deps ## Build the binary
go build -a -o php-fpm_exporter main.go

test: ## Run tests
go test -short ./...

Expand All @@ -26,4 +29,4 @@ lint: ## Run linters
golangci-lint run

fmt: ## Fix formatting issues
goimports -w .
goimports -w .