Skip to content

Instantly share code, notes, and snippets.

@smahi
Last active July 18, 2020 06:18
Show Gist options
  • Save smahi/039f54d1435ffc219da78ccb8b7b1015 to your computer and use it in GitHub Desktop.
Save smahi/039f54d1435ffc219da78ccb8b7b1015 to your computer and use it in GitHub Desktop.
Wordpress development environment based on docker, nginx, php-fpm
version: "3"
services:
db:
image: mariadb
container_name: mariadb_server
restart: always
networks:
- wp_net
volumes:
- ~/.docker/Data/MariaDB:/var/lib/mysql
environment:
TZ: Africa/Algiers
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: wpdb
MYSQL_USER: wpdbuser
MYSQL_PASSWORD: secret
code:
user: "1000:1000"
# image: wordpress:php7.4-fpm-alpine
build:
context: ./tests
container_name: wp_code
restart: always
depends_on:
- db
networks:
- wp_net
volumes:
- .:/var/www/html
- ./php-uploads.ini:/usr/local/etc/php/conf.d/uploads.ini
environment:
TZ: Africa/Algiers
WORDPRESS_DB_HOST: mariadb_server
WORDPRESS_DB_NAME: wpdb
WORDPRESS_DB_USER: wpdbuser
WORDPRESS_DB_PASSWORD: secret
web:
image: nginx
container_name: wp_web
restart: always
networks:
- wp_net
ports:
- 8080:80
volumes:
- .:/var/www/html
- ./nginx.conf:/etc/nginx/conf.d/default.conf
environment:
TZ: Africa/Algiers
adminer:
image: adminer
restart: always
networks:
- wp_net
ports:
- 8081:8080
networks:
wp_net:
FROM wordpress:php7.4-fpm-alpine
# this is needed by Codeception
RUN docker-php-ext-install pdo_mysql
# this will add WP-CLI to the container
WORKDIR /tmp
RUN curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
RUN chmod +x wp-cli.phar
RUN mv wp-cli.phar /usr/local/bin/wp
WORKDIR /var/www/html
upstream phpfpm {
server wp_code:9000 max_fails=5 fail_timeout=30s;
}
server {
listen 80;
server_name wp-plugins.local;
root /var/www/html;
index index.php;
access_log /var/log/nginx/wp-plugins-local-access.log;
error_log /var/log/nginx/wp-plugins-local-error.log;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass phpfpm;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}
file_uploads = On
memory_limit = 64M
upload_max_filesize = 64M
post_max_size = 64M
max_execution_time = 600
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment