diff --git a/Dockerfile b/Dockerfile index 123cf17..6ba9788 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,4 +16,5 @@ FROM scratch COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt COPY --from=builder /konfachcloud-discord-bot /konfachcloud-discord-bot +VOLUME /data ENTRYPOINT ["/konfachcloud-discord-bot"] diff --git a/src/bot/bot.go b/src/bot/bot.go index 4e6adc5..bb6ae63 100644 --- a/src/bot/bot.go +++ b/src/bot/bot.go @@ -42,7 +42,7 @@ func (b *Bot) Close(ctx context.Context) error { ) } -const stateFileName = "state.json" +const stateFileName = "./data/state.json" func (b *Bot) saveState() error { b.saveStateMu.Lock() @@ -57,7 +57,9 @@ func (b *Bot) saveState() error { } func Run(settings Settings) (*Bot, error) { - state := State{} + state := State{ + InitialScanLastID: make(map[string]string), + } if _, err := os.Stat(stateFileName); err == nil { f, err := os.Open(stateFileName) if err != nil { diff --git a/src/bot/hashdb.go b/src/bot/hashdb.go index a9f3ae0..afcf844 100644 --- a/src/bot/hashdb.go +++ b/src/bot/hashdb.go @@ -109,7 +109,7 @@ func (u extimagehashCodec) Unmarshal(data []byte, v any) error { } func newHashDb(hashLength int) (kv.Store[attachmentKey, goimagehash.ExtImageHash], error) { - opts := kvbadger.DefaultOptions("./db/hash") + opts := kvbadger.DefaultOptions("./data/db/hash") opts.Codec = extimagehashCodec{hashLength: hashLength} return kvbadger.NewBagerKVBinaryKey[attachmentKey, goimagehash.ExtImageHash](opts) }