davis icon indicating copy to clipboard operation
davis copied to clipboard

500 error upon login with `docker-compose-standalone`

Open RCdeWit opened this issue 1 year ago • 5 comments

I am trying to get Davis to run on my Synology NAS. I use Portainer to manage my Docker stacks.

I have a reverse proxy hosted elsewhere that connects to my NAS over Tailscale, so I think I need to use the standalone version.

I have adapted the docker-compose-standalone to the following:

version: "3.7"
name: "davis"

services:

  mysql:
    image: mariadb:10.6.10
    container_name: mysql
    environment:
      - MYSQL_ROOT_PASSWORD=${DB_ROOT_PASSWORD}
      - MYSQL_DATABASE=${DB_DATABASE}
      - MYSQL_USER=${DB_USER}
      - MYSQL_PASSWORD=${DB_PASSWORD}
    volumes:
      - /volume1/docker/davis/database:/var/lib/mysql

  davis:
    build:
      context: ../
      dockerfile: ./docker/Dockerfile-standalone
    # image: davis:latest
    # If you want to use a prebuilt image from Github
    image: ghcr.io/tchapi/davis-standalone:edge
    container_name: davis-standalone
    environment:
      - APP_ENV=prod
      - DATABASE_DRIVER=mysql
      - DATABASE_URL=mysql://${DB_USER}:${DB_PASSWORD}@mysql:3306/${DB_DATABASE}?serverVersion=mariadb-10.6.10&charset=utf8mb4
      - MAILER_DSN=smtp://${MAIL_USERNAME}:${MAIL_PASSWORD}@${MAIL_HOST}:${MAIL_PORT}
      - ADMIN_LOGIN=${ADMIN_LOGIN}
      - ADMIN_PASSWORD=${ADMIN_PASSWORD}
      - AUTH_REALM=${AUTH_REALM}
      - AUTH_METHOD=${AUTH_METHOD}
      - CALDAV_ENABLED=${CALDAV_ENABLED}
      - CARDDAV_ENABLED=${CARDDAV_ENABLED}
      - WEBDAV_ENABLED=${WEBDAV_ENABLED}
      - WEBDAV_TMP_DIR=${WEBDAV_TMP_DIR}
      - WEBDAV_PUBLIC_DIR=${WEBDAV_PUBLIC_DIR}
      - INVITE_FROM_ADDRESS=${INVITE_FROM_ADDRESS}
      - APP_TIMEZONE=${TIMEZONE}
    depends_on:
      - mysql
    ports:
      - 8444:9000

volumes:
  database:
    name: database

Basically, I have changed the port because Portainer uses :9000 and the volume to match a directory on my NAS. I have also executed bin/console doctrine:migrations:migrate through the console of the docker-standalone container, although I can't see whether it succeeded.

I can access :8444/dashboard and get a login page. Whenever I try to log in with the ADMIN_LOGIN/ADMIN_PASSWORD credentials, I am redirected to a 500 page.

The logs of the davis-standalone container don't show anything off, although Portainer does give it the Unhealthy label.

Any help would be much appreciated!

RCdeWit avatar Jun 11 '24 10:06 RCdeWit

Hi @RCdeWit 👋🏼

  • Did bin/console doctrine:migrations:migrate output any log at all when you ran it? You can check whether the migrations were correctly executed by connection to the database and looking for the tables: there should be around 15 of them, like calendars, principals, etc

  • Being redirected to a 500 page upon login tends to indicate that it cannot find the DB somehow, I'd say, or that some file permissions are not correct

  • Can you have a look in /var/www/davis/var/log: there should be a prod.log file here that should contain more info on the 500 in the PHP realm

Keep me posted!

tchapi avatar Jun 11 '24 21:06 tchapi

I believe i'm getting the same error on fresh install of the standalone version. It returns an HTTP 500 Internal Server Error. Screenshot 2024-06-14 124230

lambolighting avatar Jun 14 '24 09:06 lambolighting

@lambolighting this is very likely different — you seem to be missing the APP_ENV=prod variable?

tchapi avatar Jun 15 '24 20:06 tchapi

I get the same error with the ghcr.io/tchapi/davis:latest image. bin/console doctrine:migrations:migrate produces:

In StreamHandler.php line 149:

  The stream or file "/var/www/davis/var/log/prod.log" could not be opened in
   append mode: Failed to open stream: Permission denied
  The exception occurred while attempting to log: Error thrown while running
  command "doctrine:migrations:migrate". Message: "An exception occurred in t
  he driver: SQLSTATE[HY000] [2002] Connection refused"
  Context: {"exception":{},"command":"doctrine:migrations:migrate","message":
  "An exception occurred in the driver: SQLSTATE[HY000] [2002] Connection ref
  used"}

And in /var/www/davis/var/log are no logs, but the folder is owned by root

paul-m-koch avatar Jun 28 '24 13:06 paul-m-koch

Interesting @paul-m-koch, thanks for the details

  • it seems the container can't connect to the database in your case, when you run the migrations
  • on top of that, there is a permission problem with the log folder → I'll have a look quickly!

tchapi avatar Jun 28 '24 16:06 tchapi

Hello!

Just wrote a k3s deployment for the 5.0.2 container, standalone as well. I do get to the login, but the login does not work - so I am trying to manually put the migrations in to see if that helps. However, whenever I visit the front page, I see the following:

image

Any ideas as to what this could be? Thanks!

IngwiePhoenix avatar Dec 01 '24 13:12 IngwiePhoenix

Running the DB migrations through the CLI was the trick - they had never been applied, so the app didn't work. I had also forgot to set APP_ENV.

Since the standalone container uses supervised, it'd be nice if it would optionally try to run migrations.

IngwiePhoenix avatar Dec 01 '24 13:12 IngwiePhoenix

it'd be nice if it would optionally try to run migrations.

I would happily review a PR if you find some time to propose a way to do it :)

note: Fixed the deprecation warning in the screenshot you shared in https://github.com/tchapi/davis/commit/19b2fdec02f9bc72ec8f6105a5ea493a52ffd199

tchapi avatar Dec 01 '24 20:12 tchapi