Small tweaks to configuration flow, Dockerfile for running as a container

This commit is contained in:
Jarno Rankinen 2024-03-26 21:57:15 +02:00
parent 26dc3fa6fc
commit f66ce030cf
4 changed files with 30 additions and 13 deletions

13
Dockerfile Normal file
View File

@ -0,0 +1,13 @@
FROM golang:1.22 as builder
WORKDIR /src
COPY . /src
RUN CGO_ENABLED=0 go build -o /hydroxide-push ./cmd/hydroxide-push/
FROM alpine:latest
VOLUME /data
COPY --from=builder /hydroxide-push /
ENV HOME=/data
WORKDIR /data
ENTRYPOINT ["/hydroxide-push"]
CMD ["notify"]

View File

@ -1,8 +0,0 @@
FROM scratch
COPY hydroxide-push /
ENV HOME=/data
ENV HYDROXIDE_BRIDGE_PASS="supersecretpassword"
WORKDIR /data
ENTRYPOINT ["/hydroxide-push"]
CMD ["notify"]

View File

@ -229,20 +229,30 @@ func main() {
}
case "setup-ntfy":
err = cfg.Read()
if err != nil {
fmt.Println(err)
}
var new string
if cfg.URL != "" && cfg.Topic != "" {
fmt.Printf("Current push endpoint: %s\n", cfg.String())
new = "new "
}
scanner := bufio.NewScanner(os.Stdin)
fmt.Printf("Input push server URL (e.g. 'http://ntfy.sh') : ")
fmt.Printf("Input %spush server URL (e.g. 'http://ntfy.sh') : ", new)
scanner.Scan()
cfg.URL = scanner.Text()
scanner = bufio.NewScanner(os.Stdin)
fmt.Printf("Input push topic (e.g. my-proton-notifications)\nLeave blank to generate a random one: ")
fmt.Printf("Input push topic (e.g. my-proton-notifications): ")
scanner.Scan()
cfg.Topic = scanner.Text()
fmt.Printf("Using URL %s\n", cfg.String())
err = cfg.Save()
if err != nil {
log.Fatal(err)
fmt.Println(err)
os.Exit(1)
}
log.Println("Notification configuration saved")
fmt.Println("Notification configuration saved")
case "notify":
authManager := auth.NewManager(newClient)
eventsManager := events.NewManager()

View File

@ -87,7 +87,9 @@ func Login(cfg *NtfyConfig, be backend.Backend) {
log.Println("login first using " + executable + " auth <protonmail username>")
log.Fatalln("then setup ntfy using " + executable + "setup-ntfy")
}
cfg.BridgePw = os.Getenv("HYDROXIDE_BRIDGE_PASSWORD")
if cfg.BridgePw == "" {
cfg.BridgePw = os.Getenv("HYDROXIDE_BRIDGE_PASSWORD")
}
if cfg.BridgePw == "" {
scanner := bufio.NewScanner(os.Stdin)
fmt.Printf("Bridge password: ")