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
|
||||
|
||||
import (
|
||||
"ewintr.nl/matrix-kagisum/bot"
|
||||
"fmt"
|
||||
"golang.org/x/exp/slog"
|
||||
"os"
|
||||
"os/signal"
|
||||
|
||||
"ewintr.nl/matrix-kagisum/bot"
|
||||
"golang.org/x/exp/slog"
|
||||
)
|
||||
|
||||
func main() {
|
||||
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)
|
||||
|
||||
//res, err := kagi.Summarize("https://ewintr.nl/shitty-ssg/why-i-built-my-own-shitty-static-site-generator/")
|
||||
//if err != nil {
|
||||
// fmt.Println(err)
|
||||
//}
|
||||
kagi := bot.NewKagi("https://kagi.com/api/v0", getParam("KAGI_API_KEY", ""))
|
||||
|
||||
mtrxConf := bot.MatrixConfig{
|
||||
Homeserver: getParam("MATRIX_HOMESERVER", "http://localhost/"),
|
||||
|
@ -31,21 +24,21 @@ func main() {
|
|||
AcceptInvites: getParam("MATRIX_ACCEPT_INVITES", "false") == "true",
|
||||
}
|
||||
|
||||
bot := bot.NewBot(mtrxConf, kagi, logger)
|
||||
if err := bot.Init(); err != nil {
|
||||
logger.Error("error running matrix bot: %v", slog.String("error", err.Error()))
|
||||
ks := bot.NewBot(mtrxConf, kagi, logger)
|
||||
if err := ks.Init(); err != nil {
|
||||
logger.Error("error running matrix ks: %v", slog.String("error", err.Error()))
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
go bot.Run()
|
||||
defer bot.Close()
|
||||
logger.Info("matrix bot started")
|
||||
go ks.Run()
|
||||
defer ks.Close()
|
||||
logger.Info("matrix ks started")
|
||||
|
||||
done := make(chan os.Signal)
|
||||
signal.Notify(done, os.Interrupt)
|
||||
<-done
|
||||
|
||||
logger.Info("matrix bot stopped")
|
||||
logger.Info("matrix ks stopped")
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue