From 34b3156d641c66bee64711bef597f236efa21a1b Mon Sep 17 00:00:00 2001 From: Melora Hugues Date: Sat, 28 Jan 2023 15:11:36 +0100 Subject: [PATCH] Add Dockerfile This commit adds a first working Dockerfile for this program, as well as instructions on how to use it. This will need more detailing in the future, but this will do for now. --- Dockerfile | 14 ++++++++++++++ README.md | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d83665f --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +FROM golang:1.19 AS builder +WORKDIR /go/src/git.faercol.me/public-ip-tracker/ +COPY tracker ./ +RUN CGO_ENABLED=0 make build + +# Replace with from scratch later on +FROM alpine:latest +WORKDIR /root +COPY --from=builder go/src/git.faercol.me/public-ip-tracker/build/tracker ./ + +VOLUME [ "/config" ] + +ENTRYPOINT [ "./tracker" ] +CMD [ "-config", "/config/config.json" ] diff --git a/README.md b/README.md index aecbdde..02fe11c 100644 --- a/README.md +++ b/README.md @@ -27,3 +27,38 @@ The relevant channel is monitored during the program execution. This allows the command to the bot in order to get the current public IP on-demand. > Insert example here + + +## Deploy + +### Configuration file + +For now, the program is configured through a JSON configuration file. Here is a sample : + +```json +{ + "telegram": { + "token": "", + "channel_id": 9999999 + }, + "polling_frequency": 5 +} +``` + + +### Docker + +You can use the provided Dockerfile to build your own image. + +```bash +docker build -t public-ip-tracker . +``` + +You can then use the provided configuration file sample, and provide it to the program using the +`/config` volume + +> I might add support for environment variables in the future. + +```bash +docker run -it -v /path/to/your/dir/with/json/file:/config public-ip-tracker +``` -- 2.45.2