Skip to content

Instantly share code, notes, and snippets.

@dbazhenov
Created March 4, 2023 14:30
Show Gist options
  • Select an option

  • Save dbazhenov/0df7c509624508ec5c079c65f9207c52 to your computer and use it in GitHub Desktop.

Select an option

Save dbazhenov/0df7c509624508ec5c079c65f9207c52 to your computer and use it in GitHub Desktop.
Docker: Nginx + PHP-FPM + Mongo
server {
listen 80;
server_name localhost;
index index.php index.html;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
root /var/www/html;
rewrite ^/(.*)/$ /$1 permanent;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass php-fpm:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_buffering off;
}
}
version: '3.9'
services:
web:
image: nginx:latest
platform: linux/arm64/v8
ports:
- '80:80'
volumes:
- ./app:/var/www/html
- ./default.conf:/etc/nginx/conf.d/default.conf
php-fpm:
image: php8-mongo
volumes:
- ./app:/var/www/html
psmdb:
image: "percona/percona-server-mongodb:6.0.4-3-arm64"
volumes:
- ./data:/data/db
restart: always
environment:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: secret
MONGO_INITDB_DATABASE: database
ports:
- "27017:27017"
FROM arm64v8/php:8.2-fpm
RUN apt-get -y update \
&& apt-get install -y libssl-dev pkg-config libzip-dev unzip git
RUN pecl install zlib zip mongodb \
&& docker-php-ext-enable zip \
&& docker-php-ext-enable mongodb
# SETUP PHP-FPM CONFIG SETTINGS (max_children / max_requests)
RUN echo 'pm.max_children = 35' >> /usr/local/etc/php-fpm.d/zz-docker.conf && \
echo 'pm.max_requests = 500' >> /usr/local/etc/php-fpm.d/zz-docker.conf
# Install composer (updated via entry point)
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment