Open dglassow opened 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.
These commands also fail with the www user, but can be successfully run as root:
$ composer install
$ php artisan key:generate
$ php artisan migrate
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":{}}
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.
Create a new user (e.g., webmaster) and add them to the Docker group:
$ sudo useradd -m webmaster
$ sudo usermod -aG docker webmaster
Switch to the new user (webmaster):
$ su webmaster
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
Copy .env.example-prod
to .env
.
$ cp .env.example-prod .env
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.
Access the "ogame-app" Docker container:
$ docker exec -it ogame-app /bin/bash
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 changeAPP_ENV
fromproduction
tolocal
.
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:
Expected behavior It should successfully install
Screenshots