markhilton / docker-php-fpm Goto Github PK
View Code? Open in Web Editor NEWDocker image of PHP-FPM engine
License: MIT License
Docker image of PHP-FPM engine
License: MIT License
Please add a link to this repo on https://hub.docker.com/r/crunchgeek/php-fpm/
nginx failed (111: Connection refused) while connecting to upstream, when it was running in k8s.
here is php-svc
apiVersion: v1
kind: Service
metadata:
name: php-svc
spec:
selector:
name: php
ports:
- port: 9000
name: http-php
targetPort: 9000
protocol: TCP
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-php-deploy
spec:
replicas: 1
selector:
matchLabels:
name: php
template:
metadata:
labels:
name: php
spec:
containers:
- name: php
image: crunchgeek/php-fpm:7.2
env:
- name: PHP_CRONTABS_PATH
value: /app/cronttab_scripts
ports:
- name: http-php
containerPort: 9000
volumeMounts:
- name: php-code
mountPath: /var/www/html/
- name: php-app
mountPath: /app
volumes:
- name: php-code
nfs:
path: /home/data
server: 192.168.83.143
- name: php-app
nfs:
path: /home/data/phpCron
server: 192.168.83.143
and crontab was invalid, this file /app/cronttab_scripts content below
* * * * * /usr/local/bin/php /var/www/html/lumen57/artisan schedule:run >> /dev/null 2>&1 &
This is my second attempt at setting up a Docker environment for myself so I'm still figuring things out.
Took some inspiration from your https://github.com/markhilton/docker-nginx-php-fpm-example repo, however I needed to setup MySQL and while debugging my connection errors, I noticed that PHP isn't updating edits I'm making until the service is physically restarted, which is tedious and defeats the purpose of this exercise.
My assumption is this issue exists solely in the php-fpm
container I setup, since restarting the service refreshes the file system and my changes show up, but since I'm using volumes to map my working directory to the container I would expect my changes to show up instantly. I'm not sure if I have a fundamental misunderstanding with how this all works.
Doing some research on this behavior, opcache.revalidate_freq
in the php.ini
settings seemed like a promising resolution, but overwriting this value from the default 10
seconds to 1
in my .docker/local.ini
filedoes not appear to resolve the issue.
# .docker/local.ini
[opcache]
opcache.revalidate_freq=1
# docker-compose.yml
version: '3'
services:
mysql:
container_name: mysql
image: mysql:5.7
restart: unless-stopped
tty: true
networks:
- backend
ports:
- ${DB_PORT}:3306
volumes:
- data:/var/lib/mysql
- ./.docker/my.cnf:/etc/mysql/my.cnf
environment:
MYSQL_DATABASE: ${DB_NAME}
MYSQL_PASSORD: ${DB_PASS}
MYSQL_USER: ${DB_USER}
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
SERVICE_TAGS: dev
SERVICE_NAME: mysql
nginx:
container_name: nginx
image: crunchgeek/nginx-pagespeed:1.17.3-r1
working_dir: /app
hostname: nginx
tty: true
ports:
- "80:80"
- "8080:8080"
networks:
- backend
volumes:
- .:/app
- ./.docker:/config
env_file: .env
php-fpm:
image: crunchgeek/php-fpm:7.3
working_dir: /app/public
hostname: php-fpm
tty: true
depends_on:
- mysql
container_name: php-fpm
networks:
- backend
volumes:
- .:/app
- ./.docker:/config
env_file: .env
networks:
backend:
driver: bridge
volumes:
data:
driver: local
I set environment SUPERVISORD_PATH
to my supervisor config dir and start the container, but nothing happened.
Thanks for helping!
The documentation specifies that a user may be created through environment variables as follows:
system user
PHP_UID=1000
PHP_GID=1000
PHP_HOME=/app
PHP_USER=php-fpm
will run create a system user called php-fpm with UID:GUID 1000:1000 and home directory /app, which then can be referenced in your php-fpm manager pool configuration file.
However, php-fpm is always running under user www-data [33:33], which apparently comes with the image:
.
proxy:x:13:13:proxy:/bin:/usr/sbin/nologin
www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin
backup:x:34:34:backup:/var/backups:/usr/sbin/nologin
list:x:38:38:Mailing List Manager:/var/list:/usr/sbin/nologin
irc:x:39:39:ircd:/var/run/ircd:/usr/sbin/nologin
gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/usr/sbin/nologin
nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin
systemd-timesync:x:100:103:systemd Time Synchronization,,,:/run/systemd:/bin/false
systemd-network:x:101:104:systemd Network Management,,,:/run/systemd/netif:/bin/false
systemd-resolve:x:102:105:systemd Resolver,,,:/run/systemd/resolve:/bin/false
systemd-bus-proxy:x:103:106:systemd Bus Proxy,,,:/run/systemd:/bin/false
messagebus:x:104:107::/var/run/dbus:/bin/false
Debian-exim:x:105:110::/var/spool/exim4:/bin/false
newrelic:x:999:999:New Relic daemons:/opt/newrelic:/bin/false
postfix:x:106:112::/var/spool/postfix:/bin/false
php-fpm:x:82:82::/app:/bin/false
This also presents a problem, because some apache images default to www-data [82:82]. I added a user through the environment variables, php-fpm [82:82], and though it was created, php still continues to use www-data.
Is there any way that the image could overwrite the uid and gid of www-data, in order to synchronize with whatever user apache/nginx are using?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.