Painless and production-grade docker image for hosting almost any PHP project
1.6K
Painless and production-grade docker image for hosting almost any PHP project.
Host current directory on port 8080:
docker run -it --rm `pwd`:/var/www/src/public -p 8080:80 banian/php
Using docker-compose:
version: '3'
services:
myapp:
image: banian/php
volumes:
- ./www:/var/www
ports:
- "8080:80"
restart: always
You should mount project under /var/www/src if you have a public/ directory (Most of frameworks, including Laravel) Otherwise you can simply mount it under /var/www/src/public.
All logs are stored under /var/www/logs.
GIT_REPOSimply set this environment variable and it clones/pulls repo!
fixThis script sets correct ownership for www and log files. For faster startup, fixing /var/www/src will be done in background.
logsTails all PHP and Nginx logs.
run-as-wwwUseful for running commands as www-data inside project.
Example: docker exec -it [containerName] run-as-www php artisan help
updatecomposer install and yarn install if detected. A lock file /var/www/update.lock will be created to prevent running more than once.If you have any daemon to run with your project just add config files into /etc/supervisor/conf.d
Example: Cronjob support
/etc/supervisor/conf.d/cron.conf :
[program:cron]
command = /usr/sbin/cron -f -L 15
stdout_logfile = /var/log/cron.log
stderr_logfile = /var/log/cron.log
autorestart = true
MIT
Content type
Image
Digest
Size
168.8 MB
Last updated
over 6 years ago
docker pull banian/php