antedebaas / Viesti-Reports

DMARC & SMTP-TLS Reports processor and visualizer and BIMI file hoster
https://docs.viestireports.com/
GNU Affero General Public License v3.0
82 stars 16 forks source link

All data lost when container restarted #112

Closed deanfourie1 closed 5 months ago

deanfourie1 commented 5 months ago

Issue Template

Describe the bug When the docker container is stopped,

docker compose down

and then restarted,

docker compose up -d

All data is lost and I am asked to create a new user, start from scratch

Are you using the Docker image?

Database used

Error Messages No errors, everything works well, but when the container is restarted, everything is gone, users, reports the whole lot.

Steps to Reproduce Please provide detailed steps to reproduce the problem:

  1. run the compose container
  2. set everything up via web browser, create users etc, do a initial receive.
  3. Stop the container with docker compose down
  4. Restart the container with docker compose up -d
  5. Browse the webui again, I am prompted to run DB migrations and create a new user, when done and logged in, there are no reports available.

Expected behavior All data to be retained when restarting the container.

Environment (please complete the following information):

Additional context Nothing really, that is it.

antedebaas commented 5 months ago

Are you using the provided docker compose file or your own? And if so you you post your docker compose

deanfourie1 commented 5 months ago

Hi, thanks, here is docker compose

name: dmarc-smtptls-reports
version: "2"
services:
  db:
    image: mariadb:latest
    environment:
      MYSQL_DATABASE: dmarc
      MYSQL_USER: dmarcuser
      MYSQL_PASSWORD: Password!100
      MYSQL_ROOT_PASSWORD: Password100!
    ports:
      - 3306
    restart: unless-stopped
    healthcheck:
      test: [ "CMD", "healthcheck.sh", "--su-mysql", "--connect", "--innodb_initialized" ]
      interval: 10s
      timeout: 5s
      retries: 6
  web:
    image: antedebaas/dmarc-reports:latest
    ports:
        - 0.0.0.0:8001:8080
    environment:
      TZ: Pacific/Auckland
      DATABASE_TYPE: mysql
      DATABASE_HOST: db
      DATABASE_PORT: 3306
      DATABASE_NAME: dmarc
      DATABASE_USER: dmarcuser
      DATABASE_PASSWORD: 
      MAILER_HOST: 
      MAILER_SMTPPORT: 465
      MAILER_IMAPPORT: 993
      MAILER_USER: 
      MAILER_PASSWORD: 
      DELETE_PROCESSED_MAILS: false
      ENABLE_REGISTRATION: false
      MAILCHECK_SCHEDULE: "0 * * * *"
    restart: unless-stopped
    depends_on:
      db:
        condition: service_healthy
bundyland commented 5 months ago

OMG! I really hope the mail password is not the real one. 😱

bundyland commented 5 months ago

You have to make the data persistent by mounting a volume for the mysql database:

**services: db: image: mariadb:latest volumes:

This survives a docker and/or server restart.

antedebaas commented 5 months ago

Yes that sounds like a good solution. It’s probably because the container gets recreated deleting the data

deanfourie1 commented 5 months ago

HAHA yea it was, damn!

deanfourie1 commented 5 months ago

You have to make the data persistent by mounting a volume for the mysql database:

services: db: image: mariadb:latest volumes: - ./dmarc-report-db:/var/lib/mysql

This survives a docker and/or server restart.

Yes, I thought it was strange that no volumes were being mounted in the image, I just did not know how to mount a volume correctly.

Thanks for this.

deanfourie1 commented 5 months ago

Thanks, this is now resolved.

antedebaas commented 5 months ago

Reopening as a reminder for me to change the docker compose for future users

antedebaas commented 5 months ago

added a volume in the docker-compose file