docker and make
This commit is contained in:
parent
850843bac7
commit
90d41eb115
|
@ -0,0 +1,13 @@
|
||||||
|
FROM golang:1.20-bullseye as build
|
||||||
|
RUN apt update && apt install -y libolm3 libolm-dev
|
||||||
|
|
||||||
|
WORKDIR /src
|
||||||
|
COPY . ./
|
||||||
|
RUN go mod download
|
||||||
|
RUN go build -o /matrix-kagisum ./main.go
|
||||||
|
|
||||||
|
FROM debian:bullseye
|
||||||
|
RUN apt update && apt install -y libolm3 ca-certificates openssl
|
||||||
|
|
||||||
|
COPY --from=build /matrix-kagisum /matrix-kagisum
|
||||||
|
CMD /matrix-kagisum
|
|
@ -0,0 +1,4 @@
|
||||||
|
docker-push:
|
||||||
|
docker build . -t matrix-kagisum
|
||||||
|
docker tag matrix-kagisum registry.ewintr.nl/matrix-kagisum
|
||||||
|
docker push registry.ewintr.nl/matrix-kagisum
|
29
main.go
29
main.go
|
@ -1,24 +1,17 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"ewintr.nl/matrix-kagisum/bot"
|
|
||||||
"fmt"
|
|
||||||
"golang.org/x/exp/slog"
|
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
|
|
||||||
|
"ewintr.nl/matrix-kagisum/bot"
|
||||||
|
"golang.org/x/exp/slog"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
logger := slog.New(slog.NewTextHandler(os.Stderr, nil))
|
logger := slog.New(slog.NewTextHandler(os.Stderr, nil))
|
||||||
apiKey := getParam("KAGI_API_KEY", "")
|
|
||||||
fmt.Println(apiKey)
|
|
||||||
|
|
||||||
kagi := bot.NewKagi("https://kagi.com/api/v0", apiKey)
|
kagi := bot.NewKagi("https://kagi.com/api/v0", getParam("KAGI_API_KEY", ""))
|
||||||
|
|
||||||
//res, err := kagi.Summarize("https://ewintr.nl/shitty-ssg/why-i-built-my-own-shitty-static-site-generator/")
|
|
||||||
//if err != nil {
|
|
||||||
// fmt.Println(err)
|
|
||||||
//}
|
|
||||||
|
|
||||||
mtrxConf := bot.MatrixConfig{
|
mtrxConf := bot.MatrixConfig{
|
||||||
Homeserver: getParam("MATRIX_HOMESERVER", "http://localhost/"),
|
Homeserver: getParam("MATRIX_HOMESERVER", "http://localhost/"),
|
||||||
|
@ -31,21 +24,21 @@ func main() {
|
||||||
AcceptInvites: getParam("MATRIX_ACCEPT_INVITES", "false") == "true",
|
AcceptInvites: getParam("MATRIX_ACCEPT_INVITES", "false") == "true",
|
||||||
}
|
}
|
||||||
|
|
||||||
bot := bot.NewBot(mtrxConf, kagi, logger)
|
ks := bot.NewBot(mtrxConf, kagi, logger)
|
||||||
if err := bot.Init(); err != nil {
|
if err := ks.Init(); err != nil {
|
||||||
logger.Error("error running matrix bot: %v", slog.String("error", err.Error()))
|
logger.Error("error running matrix ks: %v", slog.String("error", err.Error()))
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
go bot.Run()
|
go ks.Run()
|
||||||
defer bot.Close()
|
defer ks.Close()
|
||||||
logger.Info("matrix bot started")
|
logger.Info("matrix ks started")
|
||||||
|
|
||||||
done := make(chan os.Signal)
|
done := make(chan os.Signal)
|
||||||
signal.Notify(done, os.Interrupt)
|
signal.Notify(done, os.Interrupt)
|
||||||
<-done
|
<-done
|
||||||
|
|
||||||
logger.Info("matrix bot stopped")
|
logger.Info("matrix ks stopped")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue