From c9f6ceb1829d9ef4a60446556ddb9ef3dedc9926 Mon Sep 17 00:00:00 2001 From: Thomas Klaehn Date: Fri, 10 Apr 2026 09:26:03 +0200 Subject: [PATCH] Dockerise: add Dockerfile, compose, gitignore token from config --- .gitignore | 2 ++ Dockerfile | 10 ++++++++++ config/{config.json => config.example.json} | 2 +- docker-compose.yml | 8 ++++++++ 4 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 .gitignore create mode 100644 Dockerfile rename config/{config.json => config.example.json} (99%) create mode 100644 docker-compose.yml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6d9deac --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +bin/ +config/config.json diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..3e4d4d1 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,10 @@ +FROM golang:1.24-alpine AS builder +WORKDIR /build +COPY go.mod go.sum ./ +RUN go mod download +COPY . . +RUN go build -buildvcs=false -o pvcollect . + +FROM alpine:latest +COPY --from=builder /build/pvcollect /usr/bin/pvcollect +ENTRYPOINT ["/usr/bin/pvcollect", "-c", "/etc/pvcollect/config.json"] diff --git a/config/config.json b/config/config.example.json similarity index 99% rename from config/config.json rename to config/config.example.json index 13100d2..090a23d 100644 --- a/config/config.json +++ b/config/config.example.json @@ -89,4 +89,4 @@ ] } ] -} +} \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..b073799 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,8 @@ +services: + pvcollect: + build: . + container_name: pvcollect + restart: unless-stopped + network_mode: host + volumes: + - /srv/energy/pvcollect/config.json:/etc/pvcollect/config.json:ro