davis icon indicating copy to clipboard operation
davis copied to clipboard

Can not make docker compose file to work

Open BaccanoMob opened this issue 8 months ago • 5 comments

Steps I did:

  1. git clone https://github.com/tchapi/davis.git
  2. cd davis/docker
  3. docker compose up -d and wait for build to finish (I also tried prebuilt images from github edge)
  4. Open <IP_ADDRESS>:9000/login, and user/pass as admin/admin => Submit

Image

  1. docker compose down
  2. Change prod to dev and follow your this comment
  3. docker compose up -d and wait for build to finish (I also tried prebuilt images from github edge)
  4. Open <IP_ADDRESS>:9000/login

Image

Stack Trace:

UnexpectedValueException:
The stream or file "/var/www/davis/var/log/dev.log" could not be opened in append mode: Failed to open stream: Permission denied
The exception occurred while attempting to log: Uncaught PHP Exception UnexpectedValueException: "The stream or file "/var/www/davis/var/log/dev.log" could not be opened in append mode: Failed to open stream: Permission denied
The exception occurred while attempting to log: Uncaught PHP Exception UnexpectedValueException: "The stream or file "/var/www/davis/var/log/dev.log" could not be opened in append mode: Failed to open stream: Permission denied
The exception occurred while attempting to log: Matched route "app_login".
Context: {"route":"app_login","route_parameters":{"_route":"app_login","_controller":"App\\Controller\\SecurityController::login"},"request_uri":"http:\/\/100.84.174.23:9000\/login","method":"GET"}" at StreamHandler.php line 156
Context: {"exception":{}}" at StreamHandler.php line 156
Context: {"exception":{}}

  at /var/www/davis/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:156
  at Monolog\Handler\StreamHandler->write(object(LogRecord))
     (/var/www/davis/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php:44)
  at Monolog\Handler\AbstractProcessingHandler->handle(object(LogRecord))
     (/var/www/davis/vendor/monolog/monolog/src/Monolog/Logger.php:391)
  at Monolog\Logger->addRecord(object(Level), 'Uncaught PHP Exception UnexpectedValueException: "The stream or file "/var/www/davis/var/log/dev.log" could not be opened in append mode: Failed to open stream: Permission deniedThe exception occurred while attempting to log: Uncaught PHP Exception UnexpectedValueException: "The stream or file "/var/www/davis/var/log/dev.log" could not be opened in append mode: Failed to open stream: Permission deniedThe exception occurred while attempting to log: Matched route "app_login".Context: {"route":"app_login","route_parameters":{"_route":"app_login","_controller":"App\\\\Controller\\\\SecurityController::login"},"request_uri":"http:\\/\\/100.84.174.23:9000\\/login","method":"GET"}" at StreamHandler.php line 156Context: {"exception":{}}" at StreamHandler.php line 156', array('exception' => object(UnexpectedValueException)))
     (/var/www/davis/vendor/monolog/monolog/src/Monolog/Logger.php:581)
  at Monolog\Logger->log(object(Level), 'Uncaught PHP Exception UnexpectedValueException: "The stream or file "/var/www/davis/var/log/dev.log" could not be opened in append mode: Failed to open stream: Permission deniedThe exception occurred while attempting to log: Uncaught PHP Exception UnexpectedValueException: "The stream or file "/var/www/davis/var/log/dev.log" could not be opened in append mode: Failed to open stream: Permission deniedThe exception occurred while attempting to log: Matched route "app_login".Context: {"route":"app_login","route_parameters":{"_route":"app_login","_controller":"App\\\\Controller\\\\SecurityController::login"},"request_uri":"http:\\/\\/100.84.174.23:9000\\/login","method":"GET"}" at StreamHandler.php line 156Context: {"exception":{}}" at StreamHandler.php line 156', array('exception' => object(UnexpectedValueException)))
     (/var/www/davis/vendor/symfony/http-kernel/EventListener/ErrorListener.php:171)
  at Symfony\Component\HttpKernel\EventListener\ErrorListener->logException(object(UnexpectedValueException), 'Uncaught PHP Exception UnexpectedValueException: "The stream or file "/var/www/davis/var/log/dev.log" could not be opened in append mode: Failed to open stream: Permission deniedThe exception occurred while attempting to log: Uncaught PHP Exception UnexpectedValueException: "The stream or file "/var/www/davis/var/log/dev.log" could not be opened in append mode: Failed to open stream: Permission deniedThe exception occurred while attempting to log: Matched route "app_login".Context: {"route":"app_login","route_parameters":{"_route":"app_login","_controller":"App\\\\Controller\\\\SecurityController::login"},"request_uri":"http:\\/\\/100.84.174.23:9000\\/login","method":"GET"}" at StreamHandler.php line 156Context: {"exception":{}}" at StreamHandler.php line 156', 'critical')
     (/var/www/davis/vendor/symfony/http-kernel/EventListener/ErrorListener.php:72)
  at Symfony\Component\HttpKernel\EventListener\ErrorListener->logKernelException(object(ExceptionEvent), 'kernel.exception', object(TraceableEventDispatcher))
     (/var/www/davis/vendor/symfony/event-dispatcher/Debug/WrappedListener.php:115)
  at Symfony\Component\EventDispatcher\Debug\WrappedListener->__invoke(object(ExceptionEvent), 'kernel.exception', object(TraceableEventDispatcher))
     (/var/www/davis/vendor/symfony/event-dispatcher/EventDispatcher.php:206)
  at Symfony\Component\EventDispatcher\EventDispatcher->callListeners(array(object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener)), 'kernel.exception', object(ExceptionEvent))
     (/var/www/davis/vendor/symfony/event-dispatcher/EventDispatcher.php:56)
  at Symfony\Component\EventDispatcher\EventDispatcher->dispatch(object(ExceptionEvent), 'kernel.exception')
     (/var/www/davis/vendor/symfony/event-dispatcher/Debug/TraceableEventDispatcher.php:122)
  at Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher->dispatch(object(ExceptionEvent), 'kernel.exception')
     (/var/www/davis/vendor/symfony/http-kernel/HttpKernel.php:241)
  at Symfony\Component\HttpKernel\HttpKernel->handleThrowable(object(UnexpectedValueException), object(Request), 1)
     (/var/www/davis/vendor/symfony/http-kernel/HttpKernel.php:134)
  at Symfony\Component\HttpKernel\HttpKernel->terminateWithException(object(UnexpectedValueException), object(Request))
     (/var/www/davis/vendor/symfony/http-kernel/EventListener/DebugHandlersListener.php:84)
  at Symfony\Component\HttpKernel\EventListener\DebugHandlersListener::Symfony\Component\HttpKernel\EventListener\{closure}(object(UnexpectedValueException))
     (/var/www/davis/vendor/symfony/error-handler/ErrorHandler.php:538)
  at Symfony\Component\ErrorHandler\ErrorHandler->handleException(object(UnexpectedValueException))                
compose.yml and .env (its the same in the example but you can click to open the drop down)
version: "3.7"
name: "davis-docker"

services:

  nginx:
    image: nginx:1.25-alpine
    container_name: nginx
    command: "/bin/sh -c 'while :; do sleep 6h & wait $${!}; nginx -s reload; done & nginx -g \"daemon off;\"'"
    depends_on:
      - davis
    volumes:
      - davis_www:/var/www/davis
      - type: bind
        source: ./configurations/nginx.conf
        target: /etc/nginx/conf.d/default.conf
    ports:
      - 9000:80

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

  davis:
    build:
      context: ../
      dockerfile: ./docker/Dockerfile
      args:
        fpm_user: 101:101
    image: davis:latest
    # If you want to use a prebuilt image from Github
    # image: ghcr.io/tchapi/davis:edge
    container_name: davis
    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}
      - WEBDAV_HOMES_DIR=${WEBDAV_HOMES_DIR}
      - INVITE_FROM_ADDRESS=${INVITE_FROM_ADDRESS}
      - APP_TIMEZONE=${TIMEZONE}
    depends_on:
      - mysql
    volumes:
      - davis_www:/var/www/davis

volumes:
  davis_www:
    name: davis_www
  database:
    name: database
# For the MariaDB container mainly
DB_ROOT_PASSWORD=notSoSecure

TIMEZONE=Europe/Paris

# The Davis database, user and password
DB_DATABASE=davis
DB_USER=davis_user
DB_PASSWORD=davis_password

# For the Davis app
ADMIN_LOGIN=admin
ADMIN_PASSWORD=admin

AUTH_REALM=SabreDAV
AUTH_METHOD=Basic

CALDAV_ENABLED=true
CARDDAV_ENABLED=true
WEBDAV_ENABLED=false

WEBDAV_TMP_DIR='/tmp'
WEBDAV_PUBLIC_DIR='/webdav'
WEBDAV_HOMES_DIR=

[email protected]
MAIL_HOST=smtp.myprovider.com
MAIL_PORT=587
MAIL_USERNAME=userdav
MAIL_PASSWORD=test

I actually tried the standalone version first (typed in while checking your docker compose examples), there it looped in login screen and wont login. Then I deleted everything and did the all the steps I typed above.

BaccanoMob avatar Apr 22 '25 19:04 BaccanoMob

Hi @BaccanoMob

Did you run the migrations as indicated in the README (after your point 3.) ?

tchapi avatar Apr 22 '25 19:04 tchapi

My bad it works now, I looked up docker compose examples, and went straight to configurations section of readme for info on envs because almost all services be like docker compose up -d and use it.

I recommend you put a docker specific README file inside docker folder because I just noticed the configuration section I mentioned was for barebone setup's instructions and docker's instruction was even further down.

Ill check whether standalone version still loops or not when logging in then close this issue if everything is alright.

BaccanoMob avatar Apr 22 '25 20:04 BaccanoMob

Okay, I tried the standalone version (sqlite), it logs in now with admin/admin but I cant create new users. I get same 500 Internal Server Error. I did chown -R www-data: /data as well as migrations.

I tried with above example again (nginx+mysql+davis), I can create users in this but /dav and / still gives server error and I can not login anybody other than admin/admin even if they have admin prems (made sure all dav flags are true for both cases)

BaccanoMob avatar Apr 22 '25 20:04 BaccanoMob

Ran in the same issue here, using default docker/docker-compose.yml. Running the migration script from the README.md like mentioned above solved the HTTP 500 Internal Server Error: docker exec -it davis sh -c "APP_ENV=prod bin/console doctrine:migrations:migrate --no-interaction"

By the way: While debugging I also found out that the code runs into ClassNotFoundError when started in dev-mode (APP_ENV=dev) within a docker container, because WebProfilerBundle is missing there in the vendor packages (see grep ... below).

Symfony\Component\ErrorHandler\Error\ClassNotFoundError:
Attempted to load class "WebProfilerBundle" from namespace "Symfony\Bundle\WebProfilerBundle".
Did you forget a "use" statement for another namespace?

  at /var/www/davis/vendor/symfony/framework-bundle/Kernel/MicroKernelTrait.php:143
  at App\Kernel->registerBundles()
     (/var/www/davis/vendor/symfony/http-kernel/Kernel.php:339)
  at Symfony\Component\HttpKernel\Kernel->initializeBundles()
     (/var/www/davis/vendor/symfony/http-kernel/Kernel.php:743)
  at Symfony\Component\HttpKernel\Kernel->preBoot()
     (/var/www/davis/vendor/symfony/http-kernel/Kernel.php:170)
  at Symfony\Component\HttpKernel\Kernel->handle(object(Request))
     (/var/www/davis/vendor/symfony/runtime/Runner/Symfony/HttpKernelRunner.php:35)
  at Symfony\Component\Runtime\Runner\Symfony\HttpKernelRunner->run()
     (/var/www/davis/vendor/autoload_runtime.php:29)
  at require_once('/var/www/davis/vendor/autoload_runtime.php')
     (/var/www/davis/public/index.php:10)        
/var/www/davis/vendor # grep -rnw './symfony' -e 'WebProfilerBundle'
./symfony/dependency-injection/Loader/UndefinedExtensionHandler.php:27:        'web_profiler' => 'WebProfilerBundle',
./symfony/framework-bundle/CHANGELOG.md:604: * added stopwatch helper to time templates with the WebProfilerBundle
./symfony/twig-bundle/CacheWarmer/TemplateCacheWarmer.php:51:                 * the current environment. For example, the WebProfilerBundle shouldn't be available in the prod
./symfony/error-handler/Resources/assets/js/exception.js:1:/* This file is based on WebProfilerBundle/Resources/views/Profiler/base_js.html.twig.
./symfony/error-handler/Resources/assets/css/exception.css:1:/* This file is based on WebProfilerBundle/Resources/views/Profiler/profiler.css.twig.
./symfony/twig-bridge/CHANGELOG.md:183: * added stopwatch tag to time templates with the WebProfilerBundle

But this is consistant: do not ship development dependencies in production images.

akramer-zibra avatar May 20 '25 19:05 akramer-zibra

But this is consistant: do not ship development dependencies in production images.

Yes exactly — this is expected, as we only install the production dependencies in the Docker container 👌🏼

tchapi avatar May 20 '25 19:05 tchapi