Skip to content

Instantly share code, notes, and snippets.

@MisterDaniels
Created November 10, 2021 12:03
Show Gist options
  • Save MisterDaniels/ef7ee9962993bd891a6c995266847e52 to your computer and use it in GitHub Desktop.
Save MisterDaniels/ef7ee9962993bd891a6c995266847e52 to your computer and use it in GitHub Desktop.
Wordpress docker
# Ambient variables
.env
# Git folder
.git
# Docker compose, because, don't
docker-compose.yml
# Ignore files '-'
.dockerignore
.gitignore
MYSQL_DB=wordpress
MYSQL_ROOT_PASSWORD=root
MYSQL_USER=user
MYSQL_PASSWORD=user
version: '3'
services:
nginx:
depends_on:
- wordpress
image: nginx:latest
container_name: server
restart: unless-stopped
ports:
- '8090:80'
volumes:
- ./wordpress:/var/www/html
- ./logs:/var/logs/nginx
- ./configs:/etc/nginx/conf.d
links:
- wordpress
extra_hosts:
- "fotogea.photobookfinal.com:127.0.0.1"
- "modelo.photobookfinal.com:127.0.0.1"
wordpress:
depends_on:
- database
image: wordpress:5.5.1-php7.4-fpm
container_name: wordpress
restart: unless-stopped
env_file: .env
environment:
- WORDPRESS_DB_HOST:database
- WORDPRESS_DB_USER:$MYSQL_USER
- WORDPRESS_DB_PASSWORD:$MYSQL_PASSWORD
- WORDPRESS_DB_NAME:$MYSQL_DB
ports:
- '9000:9000'
volumes:
- ./wordpress:/var/www/html
links:
- database
database:
image: mariadb:10.3
command: --innodb-flush-method=fsync
container_name: database
restart: unless-stopped
env_file: .env
environment:
- MYSQL_DATABASE=$MYSQL_DB
- MYSQL_ROOT_PASSWORD=$MYSQL_ROOT_PASSWORD
- MYSQL_USER=$MYSQL_USER
- MYSQL_PASSWORD=$MYSQL_PASSWORD
ports:
- '3307:3306'
volumes:
- ./database:/var/lib/mysql
# Install Nginx Envornment
FROM nginx
# Delete the standard files of Nginx
RUN rm -r /usr/share/nginx/html
RUN mkdir /usr/share/nginx/html
# Copy all the Wordpres data to Nginx html in the image
COPY html /usr/share/nginx/html
server {
listen 80;
server_name localhost;
root /var/www/html;
index index.php;
access_log /var/log/nginx/localhost-access.log;
error_log /var/log/nginx/localhost-error.log;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass wordpress:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment