add volume
All checks were successful
docker / build-docker (linux/amd64) (push) Successful in 1m2s
docker / build-docker (linux/arm64) (push) Successful in 2m50s

This commit is contained in:
royalcat 2024-06-27 17:01:09 +03:00
parent 70b506036a
commit 34d1243e06
3 changed files with 6 additions and 3 deletions

View file

@ -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"]

View file

@ -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 {

View file

@ -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)
}