Sign inSign up

bennett8857/laravel-app-12-php8.5

By bennett8857

•Updated 7 months ago

Ready-to-use Laravel 12 + PHP 8.5-FPM base image for rapid backend dev.

Image
Languages & frameworks
Developer tools
0

376

bennett8857/laravel-app-12-php8.5 repository overview

⁠Laravel 12 + PHP 8.5-FPM Base Image

This repository provides a lightweight and ready-to-use Docker image for Laravel 12 running on PHP 8.5-FPM. It is designed to be a clean starting point for backend development, coming with all the essential PHP extensions required by Laravel.

⁠📦 What's Included

  • PHP 8.5-FPM
  • Laravel 12.x (Fresh installation)
  • Composer (Latest version)
  • Required PHP Extensions: pdo_mysql, mbstring, exif, pcntl, bcmath, gd, zip

⁠🚀 How to Use

Since this image runs PHP-FPM, it needs to be paired with a web server like Nginx. The easiest way to spin up the environment is using Docker Compose.

⁠1. Create a docker-compose.yml

Create a file named docker-compose.yml in your project root and paste the following configuration:

services:
  app:
    image: bennett8857/laravel-app-12-php8.5:v1
    container_name: laravel_app
    restart: unless-stopped
    tty: true
    volumes:
      # Uncomment the line below to bind mount your local code for development:
      # - ./src:/var/www
      - app_data:/var/www
    networks:
      - laravel-net

  web:
    image: nginx:alpine
    container_name: laravel_nginx
    restart: unless-stopped
    ports:
      - "8000:80"
    volumes:
      - app_data:/var/www
      - ./nginx/conf.d/:/etc/nginx/conf.d/
    networks:
      - laravel-net
    depends_on:
      - app

networks:
  laravel-net:
    driver: bridge

volumes:
  app_data:
⁠2. Create the Nginx Config

Create a folder structure nginx/conf.d/ and inside it, create a file named app.conf:

server {
    listen 80;
    index index.php index.html;
    root /var/www/public;

    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass app:9000;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
    }

    location / {
        try_files $uri $uri/ /index.php?$query_string;
        gzip_static on;
    }
}
⁠3. Start the Environment

Run the following command to start the containers in the background:

docker compose up -d

Your Laravel application will now be available at http://localhost:8000.

⁠⚠️ Important Notes

1. Generate APP_KEY If you are starting a new project or running this for the first time without a mapped .env, remember to copy .env.example to .env and generate a new application key:

docker exec -it laravel_app cp .env.example .env
docker exec -it laravel_app php artisan key:generate

2. SQLite Permissions If you are using the default SQLite database and encounter a readonly database error, fix the permissions by running:

docker exec -it laravel_app chown -R www-data:www-data /var/www/database
docker exec -it laravel_app chmod -R 775 /var/www/database

Tag summary

Content type

Image

Digest

sha256:6305fe69e…

Size

254.9 MB

Last updated

7 months ago

docker pull bennett8857/laravel-app-12-php8.5:v1