chore: rewrite dockerfile
Rewrite the Dockerfile to be ready for fully automating releases using GoReleaser.
This commit is contained in:
parent
1d4ec79bac
commit
772cdb52c5
2 changed files with 7 additions and 15 deletions
17
Dockerfile
17
Dockerfile
|
@ -1,23 +1,10 @@
|
|||
# Using golang:latest instead of alpine because of issues with sqlite3
|
||||
FROM golang:latest AS build
|
||||
|
||||
# Create build folder to compile tool
|
||||
WORKDIR /build
|
||||
|
||||
# Copy source files to build folder and link to the /go folder
|
||||
COPY . /build
|
||||
RUN ln -s /go/src/ /build/src
|
||||
|
||||
# Compile the tool using a Make command
|
||||
RUN make build/docker
|
||||
|
||||
|
||||
FROM debian:buster-slim
|
||||
|
||||
# Create main app folder to run from
|
||||
WORKDIR /app
|
||||
|
||||
# Copy compiled binary to release image
|
||||
COPY --from=build /build/src/fail2ban_exporter /app/fail2ban_exporter
|
||||
# (must build the binary before running docker build)
|
||||
COPY fail2ban_exporter /app/fail2ban_exporter
|
||||
|
||||
ENTRYPOINT ["/app/fail2ban_exporter"]
|
||||
|
|
5
Makefile
5
Makefile
|
@ -1,3 +1,5 @@
|
|||
.PHONY: download test fmt check/dependencies check/fmt build build/docker
|
||||
|
||||
download:
|
||||
go mod download
|
||||
|
||||
|
@ -24,3 +26,6 @@ build:
|
|||
" \
|
||||
-o fail2ban_exporter \
|
||||
exporter.go
|
||||
|
||||
build/docker: build
|
||||
docker build -t fail2ban-prometheus-exporter .
|
||||
|
|
Loading…
Reference in a new issue