Laravel Sail, a lightweight development environment for Laravel applications, streamlines the process of setting up and managing Docker containers for your project. However, users occasionally encounter the frustrating "no configuration file provided: not found" error when attempting to launch their application using the sail up command. This comprehensive guide delves into the root causes of this issue and provides detailed solutions to get your Laravel project running smoothly.
# docker-compose.yml for Laravel Sail
# Specify the version of the Docker Compose file format.
version: '3.7' # Use a version supported by your Docker Compose installation
services:
laravel.test: # Define the service for the Laravel application
build: # Build the Docker image from the context specified
context: ./vendor/laravel/sail/runtimes/8 # Path to Sail runtime
dockerfile: Dockerfile # Use the Dockerfile within the context
args:
WWWGROUP: '${WWWGROUP}' # Inject the WWWGROUP environment variable
image: sail-8/app # Image name (adjust according to Sail version)
extra_hosts: # Add extra hosts for resolving hostnames within the container
- 'host.docker.internal:host-gateway'
ports: # Expose ports from the container to the host machine
- '${APP_PORT:-80}:80' # Map host port 80 to container port 80
- '${VITE_PORT:-5173}:${VITE_PORT:-5173}' # Map Vite development server port
environment: # Define environment variables for the container
WWWUSER: '${WWWUSER}' # User ID for the webserver
LARAVEL_SAIL: 1 # Flag indicating Sail environment
XDEBUG_MODE: '${SAIL_XDEBUG_MODE:-off}' # Xdebug mode (optional)
XDEBUG_CONFIG: '${SAIL_XDEBUG_CONFIG:-client_host=host.docker.internal}' # Xdebug configuration (optional)
volumes: # Mount volumes to share data between the host and container
- '.:/var/www/html' # Mount the project directory
networks: # Define the network the service will be connected to
- sail # Uses the 'sail' network defined later
depends_on: # Specify services that must be started before this one
- mysql # Database service
- redis # Redis service
mysql: # Define the MySQL database service
image: 'mysql:8.0' # Use the official MySQL 8.0 image
ports: # Expose port 3306 from the container to the host
- '${FORWARD_DB_PORT:-3306}:3306'
environment: # Define environment variables for the MySQL service
MYSQL_ROOT_PASSWORD: '${DB_PASSWORD}' # Root password for MySQL
MYSQL_ROOT_HOST: "%" # Allow connections from any host
MYSQL_DATABASE: '${DB_DATABASE}' # Database name
MYSQL_USER: '${DB_USERNAME}' # Database username
MYSQL_PASSWORD: '${DB_PASSWORD}' # Database password
MYSQL_ALLOW_EMPTY_PASSWORD: 'false' # Disallow empty password for better security
volumes: # Mount a named volume to persist data across container restarts
- 'sail-mysql:/var/lib/mysql' # Data volume for MySQL
- './vendor/laravel/sail/database/mysql/create-testing-database.sh:/docker-entrypoint-initdb.d/10-create-testing-database.sh' # Run script for testing DB setup
networks: # Specify the network the service will be connected to
- sail # Uses the 'sail' network defined later
healthcheck: # Configure health checks for the MySQL service
test: ["CMD", "mysqladmin", "ping", "-p${DB_PASSWORD}"] # Command to check if MySQL is running
retries: 3 # Number of retries for health check
timeout: 5s # Timeout for health check
redis: # Define the Redis service
image: 'redis:alpine' # Use the official Alpine Linux based Redis image (lightweight)
ports: # Expose port 6379 from the container to the host
- '${FORWARD_REDIS_PORT:-6379}:6379'
volumes: # Mount a named volume to persist data across container restarts
- 'sail-redis:/data' # Data volume for Redis
networks: # Specify the network the service will be connected to
- sail # Uses the 'sail' network defined later
healthcheck: # Configure health checks for the Redis service
test: ["CMD", "redis-cli", "ping"] # Command to check if Redis is running
retries: 3 # Number of retries for health check
timeout: 5s # Timeout for health check
networks: # Define custom networks for services
sail: # A bridge network called 'sail'
driver: bridge # Network driver
volumes: # Define named volumes
sail-mysql: # Named volume for MySQL data persistence
driver: local # Use the local driver
sail-redis: # Named volume for Redis data persistence
driver: local # Use the local driver
0 comments:
Post a Comment