From 4d669b6bbd0bb21a3802aaf2dbb65cd1c588d0e4 Mon Sep 17 00:00:00 2001 From: Hector Date: Mon, 19 Jun 2023 19:47:24 +0100 Subject: [PATCH 1/3] rewrite dockerfile --- Dockerfile | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/Dockerfile b/Dockerfile index c895e3f..1955792 100644 --- a/Dockerfile +++ b/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"] From b918e5114927af4ac8e45605327f9a43d4e4cef3 Mon Sep 17 00:00:00 2001 From: Hector Date: Mon, 19 Jun 2023 19:47:43 +0100 Subject: [PATCH 2/3] add make command to build docker image --- Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Makefile b/Makefile index ea25c46..0fbdaff 100644 --- a/Makefile +++ b/Makefile @@ -24,3 +24,6 @@ build: " \ -o fail2ban_exporter \ exporter.go + +build/docker: build + docker build -t fail2ban-prometheus-exporter . From 4f35e6a26592c933e7626c95e61f1341f4f4b630 Mon Sep 17 00:00:00 2001 From: Hector Date: Mon, 19 Jun 2023 19:50:54 +0100 Subject: [PATCH 3/3] flag make commands as phony --- Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile b/Makefile index 0fbdaff..702a3ff 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,5 @@ +.PHONY: download test fmt check/dependencies check/fmt build build/docker + download: go mod download