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 d47246be6d
commit 6459bcbc5a
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": 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) 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() scanner.Scan()
cfg.URL = scanner.Text() cfg.URL = scanner.Text()
scanner = bufio.NewScanner(os.Stdin) 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() scanner.Scan()
cfg.Topic = scanner.Text() cfg.Topic = scanner.Text()
fmt.Printf("Using URL %s\n", cfg.String()) fmt.Printf("Using URL %s\n", cfg.String())
err = cfg.Save() err = cfg.Save()
if err != nil { if err != nil {
log.Fatal(err) fmt.Println(err)
os.Exit(1)
} }
log.Println("Notification configuration saved") fmt.Println("Notification configuration saved")
case "notify": case "notify":
authManager := auth.NewManager(newClient) authManager := auth.NewManager(newClient)
eventsManager := events.NewManager() 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.Println("login first using " + executable + " auth <protonmail username>")
log.Fatalln("then setup ntfy using " + executable + "setup-ntfy") log.Fatalln("then setup ntfy using " + executable + "setup-ntfy")
} }
if cfg.BridgePw == "" {
cfg.BridgePw = os.Getenv("HYDROXIDE_BRIDGE_PASSWORD") cfg.BridgePw = os.Getenv("HYDROXIDE_BRIDGE_PASSWORD")
}
if cfg.BridgePw == "" { if cfg.BridgePw == "" {
scanner := bufio.NewScanner(os.Stdin) scanner := bufio.NewScanner(os.Stdin)
fmt.Printf("Bridge password: ") fmt.Printf("Bridge password: ")