Merge branch '9-reduce-docker-image-size' into 'main'

Resolve "Reduce docker image size"

Closes #9

See merge request hectorjsmith/fail2ban-prometheus-exporter!15
This commit is contained in:
Hector 2021-03-27 17:34:41 +00:00
commit 7b1ff91ede

View file

@ -1,5 +1,5 @@
# Using golang:latest instead of alpine because of issues with sqlite3 # Using golang:latest instead of alpine because of issues with sqlite3
FROM golang:latest FROM golang:latest AS build
# Create build folder to compile tool # Create build folder to compile tool
WORKDIR /build WORKDIR /build
@ -11,12 +11,14 @@ RUN ln -s /go/src/ /build/src
# Compile the tool using a Make command # Compile the tool using a Make command
RUN make build/docker RUN make build/docker
FROM debian:buster-slim
# Create main app folder to run from # Create main app folder to run from
WORKDIR /app WORKDIR /app
# Move compiled binary to app folder and delete build folder # Copy compiled binary to release image
RUN mv /build/src/exporter /app/fail2ban-prometheus-exporter COPY --from=build /build/src/exporter /app/fail2ban-prometheus-exporter
RUN rm -rf /build
# Copy init script into main app folder and set as entry point # Copy init script into main app folder and set as entry point
COPY docker/run.sh /app/ COPY docker/run.sh /app/