beromir / Servas

A self-hosted bookmark management tool.
https://servas.app
GNU General Public License v3.0
526 stars 28 forks source link

docker exec command gives an error, server fails to function #94

Closed driftywinds closed 1 week ago

driftywinds commented 1 month ago

The error: -

docker exec -it servas php artisan key:generate --force

   ErrorException

  file_put_contents(/var/www/html/.env): Failed to open stream: Permission denied

  at vendor/laravel/framework/src/Illuminate/Foundation/Console/KeyGenerateCommand.php:109
    105▕
    106▕             return false;
    107▕         }
    108▕
  ➜ 109▕         file_put_contents($this->laravel->environmentFilePath(), $replaced);
    110▕
    111▕         return true;
    112▕     }
    113▕

      +15 vendor frames

  16  artisan:35
      Illuminate\Foundation\Console\Kernel::handle()

my docker-compose.yml file: - (using port 3002 because I use a reverse proxy with other apps)

version: "3"

services:
  servas:
    image: beromir/servas
    container_name: servas
    restart: unless-stopped
    ports:
      - "3002:80"
    volumes:
      - ./.env:/var/www/html/.env
      - servas-db-sqlite:/var/www/html/database/sqlite

volumes:
  servas-db-sqlite:

My .env file:-

APP_NAME=Servas
APP_ENV=production
APP_KEY=
APP_DEBUG=false
APP_URL=<my url>

SERVAS_ENABLE_REGISTRATION=true

# SQLite
DB_CONNECTION=sqlite
DB_DATABASE=/var/www/html/database/sqlite/servas.db
DB_FOREIGN_KEYS=true
beromir commented 1 month ago

Here is the same issue: #81. docker exec -it -u 1000 servas php artisan key:generate --force should work.

driftywinds commented 1 week ago

Sorry, I never got the notification of you replying until right now, when you closed the issue.

Here is the same issue: #81. docker exec -it -u 1000 servas php artisan key:generate --force should work.

Executing this command gives me this error now: -

   UnexpectedValueException

  The stream or file "/var/www/html/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream                                              : Permission denied
The exception occurred while attempting to log: file_put_contents(/var/www/html/.env): Failed to open stream: Permissio                                              n denied
Context: {"exception":{}}

  at vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:137
    133▕             }
    134▕             if (!is_resource($stream)) {
    135▕                 $this->stream = null;
    136▕
  ➜ 137▕                 throw new \UnexpectedValueException(sprintf('The stream or file "%s" could not be opened in ap                                              pend mode: '.$this->errorMessage, $url) . Utils::getRecordMessageForException($record));
    138▕             }
    139▕             stream_set_chunk_size($stream, $this->streamChunkSize);
    140▕             $this->stream = $stream;
    141▕         }

      +11 vendor frames

  12  artisan:35
      Illuminate\Foundation\Console\Kernel::handle()
driftywinds commented 1 week ago

For anyone visiting this issue, this instruction from issue #81 solved it.