Sign inSign up

rjbaquirin/php

By rjbaquirin

•Updated over 2 years ago

PHP to run laravel extracted from 8.3 sail docker file with queue:worker

Image
Web servers
0

1.2K

rjbaquirin/php repository overview

⁠Running the Laravel application

This guide outlines how to run your Laravel application container built from the Dockerfile located in the docker/8.3 directory. By following these steps, you can create a containerized environment tailored for your Laravel development workflow.

Docker Run Command Breakdown:

docker run -d \
  --name ${APP_NAME}-app \
  -v .:/var/www/html \
  -p <span class="math-inline">\{APP\_PORT\:\-80\}\:80 \\
\-e WWWUSER\=</span>{WWWUSER} \
  -e WWWGROUP=<span class="math-inline">\{WWWGROUP\} \\
\-e LARAVEL\_SAIL\=1 \\
\-e XDEBUG\_MODE\=</span>{SAIL_XDEBUG_MODE:-off} \
  -e XDEBUG_CONFIG=<span class="math-inline">\{SAIL\_XDEBUG\_CONFIG\:\-client\_host\=host\.docker\.internal\} \\
\-e IGNITION\_LOCAL\_SITES\_PATH\=</span>{PWD} \
  --network sail \
  rjbaquirin/php

Explanation:

Detached Mode and Container Naming (docker run -d --name ${APP_NAME}-app):

docker run -d: Instructs Docker to run the container in detached mode. This means the container will run in the background without requiring you to keep a terminal session open. It's ideal for long-running applications like Laravel applications. --name ${APP_NAME}-app: Assigns a meaningful name to the container based on the environment variable APP_NAME. This makes it easier to identify and manage running containers. For example, if APP_NAME is set to my-laravel-app, the container name would be my-laravel-app-app. Volume Mounting (-v .:/var/www/html):

-v .:/var/www/html: Mounts the current directory (.) of your host machine to the /var/www/html directory inside the container. This establishes a persistent connection, allowing code changes on your host machine to be automatically reflected within the container. Any files you create or modify in the host directory will be accessible at the corresponding path within the container. This is crucial for development as you can edit your Laravel code on your host machine and see the changes reflected in the running application. Port Mapping (-p ${APP_PORT:-80}:80):

-p ${APP_PORT:-80}:80: Maps the container's port (default 80, typically used for web applications) to a port on your host machine. If you don't specify APP_PORT, it defaults to 80. This allows you to access your application in a web browser by visiting http://localhost⁠:<mapped_port_number>. For example, if the container's port remains at 80 and your host uses 8080, you would access the application at http://localhost:8080⁠. This mapping exposes the application running inside the container to the outside world (your host machine) through a specific port. Environment Variables:

-e WWWUSER=${WWWUSER} and -e WWWGROUP=${WWWGROUP} (Optional): Exposes environment variables WWWUSER and WWWGROUP from your docker-compose configuration to the container. These variables are likely used to define ownership and permissions for files and directories within the container. If you're not using docker-compose or these variables aren't relevant to your setup, you can omit them. -e LARAVEL_SAIL=1: Sets the LARAVEL_SAIL environment variable to 1, indicating that you're using Laravel Sail, a development environment specifically designed for Laravel projects. This variable is likely used by the image to configure itself appropriately for Sail. **-e XDEBUG_MODE=${SAIL_XDEBUG_MODE:-off} and -e XDEBUG_CONFIG=${SAIL_XDEBUG_CONFIG:-client_host=host.docker.internal} (Optional): Configure Xdebug, a PHP debugging tool, based on your docker-compose settings. The XDEBUG_MODE variable determines whether Xdebug is enabled (on) or disabled (off), while XDEBUG_CONFIG defines configuration details, including how Xdebug communicates with the host machine. The default configuration (client_host=host.docker.internal) often works well when debugging from the host machine. These variables might not be necessary depending on your debugging needs.

Tag summary

Content type

Image

Digest

sha256:3a39ba36c…

Size

622.8 MB

Last updated

over 2 years ago

docker pull rjbaquirin/php