Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a non-root user in the ENTRYPOINT #277

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Create a non-root user in the ENTRYPOINT #277

wants to merge 1 commit into from

Conversation

ucan-lab
Copy link
Owner

@ucan-lab ucan-lab commented Aug 20, 2024

close #276

  • I created a non-root user (phper) in the Dockerfile, but moved to the ENTRYPOINT shell.

README

Usage

Create an initial Laravel project

  1. Click Use this template
  2. Git clone & change directory
  3. Execute the following command
$ task create-project

# or...

$ make create-project

# or... Linux environment

$ echo "UID=$(id -u)" >> .env
$ echo "GID=$(id -g)" >> .env
$ echo "USERNAME=$(whoami)" >> .env

$ mkdir -p src
$ docker compose build
$ docker compose --file compose.yaml --file compose-for-linux.yaml up --detach
$ docker compose exec app composer create-project --prefer-dist laravel/laravel .
$ docker compose exec app php artisan key:generate
$ docker compose exec app php artisan storage:link
$ docker compose exec app chmod -R 777 storage bootstrap/cache
$ docker compose exec app php artisan migrate

http://localhost

Create an existing Laravel project

  1. Git clone & change directory
  2. Execute the following command
$ task install

# or...

$ make install

# or... Linux environment

$ echo "UID=$(id -u)" >> .env
$ echo "GID=$(id -g)" >> .env
$ echo "USERNAME=$(whoami)" >> .env

$ docker compose build
$ docker compose --file compose.yaml --file compose-for-linux.yaml up --detach
$ docker compose exec app composer install
$ docker compose exec app cp .env.example .env
$ docker compose exec app php artisan key:generate
$ docker compose exec app php artisan storage:link
$ docker compose exec app chmod -R 777 storage bootstrap/cache

http://localhost

@ucan-lab
Copy link
Owner Author

ucan-lab commented Aug 28, 2024

Windows(WSL2)

$ echo "UID=$(id -u)" >> .env
$ echo "GID=$(id -g)" >> .env
$ echo "USERNAME=$(whoami)" >> .env

$ mkdir -p src
$ docker compose build
$ docker compose --file compose.yaml --file compose-for-linux.yaml up --detach

Cannot create app container😢
The command exec gosu “$USERNAME” “$@” running in entrypoint.sh does not allow me to switch to a user created successfully with exec gosu “$USERNAME” “$@” and enter the container.

$ docker compose logs app
app-1  | [28-Aug-2024 08:38:28] ERROR: failed to open error_log (/proc/self/fd/2): Permission denied (13)
app-1  | [28-Aug-2024 08:38:28] ERROR: failed to post process the configuration
app-1  | [28-Aug-2024 08:38:28] ERROR: FPM initialization failed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create a non-root user in the ENTRYPOINT
1 participant