Merge branch 'build/compile-docker-version-of-tool' into 'main'
Build/compile docker version of tool See merge request hectorjsmith/fail2ban-prometheus-exporter!10
This commit is contained in:
commit
542b853309
20
Dockerfile
20
Dockerfile
@ -1,10 +1,24 @@
|
|||||||
# 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
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
|
# Create main app folder to run from
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY dist/fail2ban-prometheus-exporter_linux_amd64/fail2ban-prometheus-exporter /app
|
|
||||||
COPY docker/run.sh /app
|
|
||||||
|
|
||||||
|
# Move compiled binary to app folder and delete build folder
|
||||||
|
RUN mv /build/src/exporter /app/fail2ban-prometheus-exporter
|
||||||
|
RUN rm -rf /build
|
||||||
|
|
||||||
|
# Copy init script into main app folder and set as entry point
|
||||||
|
COPY docker/run.sh /app/
|
||||||
RUN chmod +x /app/*
|
RUN chmod +x /app/*
|
||||||
|
|
||||||
ENTRYPOINT /app/run.sh
|
ENTRYPOINT /app/run.sh
|
||||||
|
6
Makefile
6
Makefile
@ -24,7 +24,11 @@ build/release:
|
|||||||
./tools/goreleaser_linux_amd64 --rm-dist --skip-publish
|
./tools/goreleaser_linux_amd64 --rm-dist --skip-publish
|
||||||
|
|
||||||
build/docker:
|
build/docker:
|
||||||
|
cd src/ && go build -o exporter \
|
||||||
|
-ldflags '-X main.version=$(shell git describe --tags) -X main.commit=${shell git rev-parse HEAD} -X "main.date=${shell date --rfc-3339=seconds}" -X main.builtBy=docker' exporter.go
|
||||||
|
|
||||||
|
docker/build-latest:
|
||||||
docker build -t registry.gitlab.com/hectorjsmith/fail2ban-prometheus-exporter:latest .
|
docker build -t registry.gitlab.com/hectorjsmith/fail2ban-prometheus-exporter:latest .
|
||||||
|
|
||||||
build/docker-tag:
|
docker/build-tag:
|
||||||
docker build -t registry.gitlab.com/hectorjsmith/fail2ban-prometheus-exporter:$(shell git describe --tags) .
|
docker build -t registry.gitlab.com/hectorjsmith/fail2ban-prometheus-exporter:$(shell git describe --tags) .
|
||||||
|
Loading…
Reference in New Issue
Block a user