Images for Laravel with PostgreSQL
2.9K
This image is based on php:${PHP_VER}-fpm
for working with the Laravel framework.
Published on Docker Hub
services:
php-dev:
image: leadsdoit/lara-php:8.4-dev
extra_hosts:
- 'host.docker.internal:host-gateway'
container_name: docker_php_dev
restart: always
volumes:
- ./:/app
# - "./script/php/php.ini:/usr/local/etc/php/conf.d/88-conf.ini:ro"
# - "./script/php/xdebug.ini:/usr/local/etc/php/conf.d/99-xdebug.ini:ro"
environment:
PHP_IDE_CONFIG: "serverName=docker_php_dev"
IGNITION_LOCAL_SITES_PATH: '${PWD}'
CONTAINER_ROLE: "app"
LARAVEL_SAIL: 1
# XDEBUG_MODE: "off"
ports:
- "127.0.0.1:9002:9000"
alias sail='sh $([ -f sail ] && echo sail || echo vendor/bin/sail)'
sail up -d --build
sail composer install
Dockerfile
FROM leadsdoit/lara-php:8.4
WORKDIR /app
COPY . .
RUN [ -d /app/vendor ] && rm -r /app/vendor || echo "Directory /app/vendor does not exist"
RUN rm -r /app/docker
RUN chown -R www-data:www-data /app \
&& chmod -R 755 /app/storage
RUN composer install --optimize-autoloader --no-dev
docker-compose.yml
x-common-app-settings: &common-app-settings
image: leadsdoit/lara-php:8.4
restart: always
working_dir: /app
networks:
- lara-network
services:
app_php:
<<: *common-app-settings
container_name: lara_app_php
environment:
CONTAINER_ROLE: "app"
depends_on:
db:
condition: service_healthy
redis:
condition: service_healthy
app_queue:
<<: *common-app-settings
container_name: lara_app_queue
environment:
CONTAINER_ROLE: "queue"
depends_on:
- app_php
app_cron:
<<: *common-app-settings
container_name: lara_app_cron
environment:
CONTAINER_ROLE: "cron"
depends_on:
- app_php
composer is installed in the image.
Also included:
The image includes the install-php-extensions script. If you need to install more extensions, add the install-php-extensions call in your Dockerfile.
FROM leadsdoit/lara-php:8.4-dev as phpdev
RUN install-php-extensions \
mysqli \
pdo_mysql
RUN install-php-extensions <extensions separated by spaces>
The image can run in the following roles:
Select the role via the CONTAINER_ROLE environment variable.
Default role is app.
The queue role supports:
If you need custom configuration, the image includes the following files you can override.
/usr/local/etc/php/conf.d/00-conf.ini
/usr/local/etc/php/conf.d/01-xdebug.ini
/etc/cron.d/app_cron
/usr/local/bin/entrypoint
The -dev image includes Xdebug.
Minimal config at:
/usr/local/etc/php/conf.d/01-xdebug.ini
The dev image includes extra CLI tools for local development:
ss for checking open ports/socketsYou can control the modes via:
on, set off to disable1, set 0 to disableMore details here
The image adds a sail user.
For Sail mode to work correctly, add this to your .env file:
APP_SERVICE=<container_name>
This script is available only in the DEV image.
If using docker
docker exec -it <container_name> dev-app
If using docker compose
docker compose exec <service_name> dev-app
When you run the script, it shows a menu:
Select a category:
1. node
2. lara
3. Exit
This category lets you install a specific Node.js version. Inside the container, it installs NVM, then installs the requested version and sets it as default.
You can install Node.js 22 directly:
docker compose exec <service_name> dev-app node install 22
After installation, Node.js is available for external calls:
docker compose exec <service_name> node -v
This category lets you create a new Laravel app inside the container.
Create a minimal docker-compose.yml in your project folder:
services:
app_php:
image: leadsdoit/lara-php:8.3-dev
restart: always
volumes:
- ./:/app
environment:
CONTAINER_ROLE: "app"
Run:
docker compose exec <service_name> dev-app lara install
After that, a new app is created in a temporary folder inside the container.
You will answer the Laravel initialization questions, and then all files are moved into /app.
After copying, you should change ownership to your user:
sudo chown -R <your_user>:<your_user> .
This command will fail if a project already exists.
Content type
Image
Digest
sha256:239a87deb…
Size
230.9 MB
Last updated
6 months ago
docker pull leadsdoit/lara-php:dev