lanedirt / OGameX

Open-source OGame redesign clone built with Laravel 11.x.
https://main.ogamex.dev
MIT License
47 stars 19 forks source link

[BUG] Install Failure: In Filesystem.php line 261: /var/www/vendor does not exist and could not be created #398

Open dglassow opened 1 week ago

dglassow commented 1 week ago

Describe the bug Amazon Linux 2023 Docker version 25.0.5, build 5dc9bcc Docker Compose version v2.29.7

To Reproduce Steps to reproduce the behavior:

  1. yum update
  2. Clone Repository to local machine
  3. rename .env
  4. docker-compose up
  5. docker exec -it ogame-app /bin/bash
  6. composer install

Expected behavior It should successfully install

Screenshots

image
dglassow commented 1 week ago

This is a permissions issue, by default your www user is the user that exec's into the container and it doesn't have access. I'm able to resolve with a -u root command, but you may want to update your readme or your container permissions accordingly.

dglassow commented 1 week ago

These commands also fail with the www user, but can be successfully run as root:

$ composer install
$ php artisan key:generate
$ php artisan migrate
dglassow commented 1 week ago

Despite completing the setup as root, the app encounters this error on login, which also seems to be permissions related

The stream or file "/var/www/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied The exception occurred while attempting to log: The stream or file "/var/www/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied The exception occurred while attempting to log: The stream or file "/var/www/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied The exception occurred while attempting to log: The stream or file "/var/www/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied The exception occurred while attempting to log: The stream or file "/var/www/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied The exception occurred while attempting to log: The stream or file "/var/www/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied The exception occurred while attempting to log: The stream or file "/var/www/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied The exception occurred while attempting to log: The stream or file "/var/www/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied The exception occurred while attempting to log: The stream or file "/var/www/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/storage/framework/views/dbb84313ac11f5807c35103f5e3b5b9a.php): Failed to open stream: Permission denied Context: {"exception":{}} Context: {"exception":{}} Context: {"exception":{}} Context: {"exception":{}} Context: {"exception":{}} Context: {"exception":{}} Context: {"exception":{}} Context: {"exception":{}} Context: {"exception":{}}
lanedirt commented 1 week ago

Hi @dglassow,

Thanks for taking the time to report this issue. You are correct in that some steps seem to be missing from the README regarding user permissions.

I reviewed the steps you followed and compared them to the demo server configuration. I think the issues you are experiencing are caused because you're trying to run the Docker containers as root, whereas the OGameX Docker containers are configured to run under a non-root user. Running Docker containers as a non-root user is a security best practice. It ensures that if the container is compromised, the attacker won't automatically gain access to the host server, making the setup more secure.

I added the extra required steps below. Could you try to follow these steps and let me know if this works for you? If this solves the problems I'll update the README with these additional steps.

Steps to Resolve:

  1. Create a new user (e.g., webmaster) and add them to the Docker group:

    $ sudo useradd -m webmaster
    $ sudo usermod -aG docker webmaster
  2. Switch to the new user (webmaster):

    $ su webmaster
  3. Clone the git repo and run the Docker commands as the webmaster user to ensure all files are created with the correct permissions.

    $ git clone https://github.com/lanedirt/OGameX.git
    $ cd OGameX
  4. Copy .env.example-prod to .env.

    $ cp .env.example-prod .env
  5. Launch the project using Docker Compose:

    $ docker compose -f docker-compose.prod.yml up -d --build --force-recreate

    Note: The default setup binds to ports 80/443. Modify docker-compose.yml if needed.

  6. Access the "ogame-app" Docker container:

    $ docker exec -it ogame-app /bin/bash
  7. Run Laravel setup commands to download composer dependencies, generate an encryption key, cache configuration and prepare the database:

    $ composer install --no-dev
    $ php artisan key:generate --force
    $ php artisan migrate --force
    $ php artisan cache:clear && php artisan config:cache && php artisan route:cache && php artisan view:cache

After completing the setup, visit https://localhost to access OGameX. You first need to create an account (no email validation), afterwards you can login using that account.

Note: The production version runs in forced-HTTPS (redirect) mode by default using a self-signed SSL certificate. If you want to access the application via HTTP, open .env and change APP_ENV from production to local.