Compare commits
4 Commits
db151257d2
...
faba4dfe92
Author | SHA1 | Date | |
---|---|---|---|
faba4dfe92 | |||
9da9291695 | |||
0ad95330d8 | |||
|
a623668c17 |
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
data
|
||||
db
|
||||
.env
|
50
Dockerfile
50
Dockerfile
@ -1,42 +1,36 @@
|
||||
FROM debian:bullseye-slim as build
|
||||
FROM debian:stable-slim
|
||||
|
||||
RUN apt-get update && \
|
||||
apt-get -qy install \
|
||||
php-fpm php-mysql php-curl php-gd php-mbstring php-xml php-xmlrpc php-soap php-intl php-zip \
|
||||
sudo wget curl ca-certificates&&\
|
||||
php-fpm php-mysql php-curl php-gd php-mbstring php-xml php-xmlrpc php-soap php-intl php-zip php-redis \
|
||||
wget sed curl tar ca-certificates less \
|
||||
mariadb-client && \
|
||||
apt-get clean
|
||||
|
||||
RUN useradd wordpress
|
||||
|
||||
COPY wordpress.conf /etc/php/7.4/fpm/pool.d/www.conf
|
||||
RUN mkdir /run/php/
|
||||
#RUN mkdir logs
|
||||
COPY config/php-fpm-wordpress.conf /tmp/www.conf
|
||||
|
||||
#USER wordpress
|
||||
WORKDIR app
|
||||
RUN wget -O wordpress.tar.gz "https://wordpress.org/latest.tar.gz"
|
||||
RUN wget https://wordpress.org/latest.tar.gz
|
||||
RUN tar -xzf wordpress.tar.gz
|
||||
RUN rm latest.tar.gz
|
||||
#ADD wordpress_files/wp-config.php /app/wordpress/wp-config.php
|
||||
#ADD wordpress_files/themes/ /app/wordpress/wp-content/themes/
|
||||
#ADD wordpress_files/plugins/ /app/wordpress/wp-content/plugins/
|
||||
#ADD wordpress_files/sunrise.php /app/wordpress/wp-content/sunrise.php
|
||||
RUN chown -R wordpress:wordpress /app/wordpress
|
||||
RUN PHP_VERSION=$(php --version | head -n 1 | cut -f2 -d" " | cut -f1,2 -d".") && \
|
||||
cp /tmp/www.conf /etc/php/$PHP_VERSION/fpm/pool.d/www.conf && \
|
||||
mkdir /run/php/ && \
|
||||
ln -s /usr/sbin/php-fpm$PHP_VERSION /usr/sbin/php-fpm && \
|
||||
sed -i '/^error_log/cerror_log = /app/log/php-fpm.log' /etc/php/$PHP_VERSION/fpm/php-fpm.conf && \
|
||||
sed -i '/^pid/cpid = /app/log/php-fpm.pid' /etc/php/$PHP_VERSION/fpm/php-fpm.conf
|
||||
|
||||
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 wp
|
||||
WORKDIR /app
|
||||
|
||||
## ESTO EN UN CRON DAILY
|
||||
#RUN sudo -u wordpress /app/wp theme update --all --path="/app/wordpress/"
|
||||
#RUN ./wp plugin update --all --path="/app/wordpress/"
|
||||
#RUN ./wp core update --all --path="/app/wordpress/"
|
||||
RUN curl -s -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar && \
|
||||
chmod +x wp-cli.phar && \
|
||||
mv wp-cli.phar /usr/local/bin/wp
|
||||
|
||||
#USER root
|
||||
ADD wordpress /tmp/wordpress
|
||||
|
||||
ADD entrypoint.sh /entrypoint.sh
|
||||
|
||||
EXPOSE 9000
|
||||
VOLUME /app/wordpress
|
||||
|
||||
CMD ["/usr/sbin/php-fpm7.4","--nodaemonize"]]
|
||||
VOLUME /app
|
||||
|
||||
ENTRYPOINT ["/bin/sh","/entrypoint.sh"]
|
||||
|
||||
CMD ["/usr/sbin/php-fpm","--nodaemonize","-O"]
|
||||
|
49
README.md
49
README.md
@ -1,13 +1,54 @@
|
||||
# Install
|
||||
# Simple custom template for a clean Wordpress installation.
|
||||
|
||||
## Pre
|
||||
|
||||
$ mkdir data db
|
||||
$ cp env.sample .env
|
||||
$ vim .env
|
||||
|
||||
Customize parameters
|
||||
|
||||
## Build
|
||||
|
||||
$ docker-compose build
|
||||
|
||||
# Run
|
||||
## Run
|
||||
|
||||
$ docker-compose up -d
|
||||
|
||||
# Config
|
||||
Access:
|
||||
|
||||
Database ENVIRONMENT on docker-compose.yml
|
||||
$ w3m http://localhost:<nginx_port>
|
||||
|
||||
## Config
|
||||
|
||||
Database credentials may edit on _.env_ file.
|
||||
|
||||
## Auto update Wordpress
|
||||
|
||||
User crontab on your hoster server.
|
||||
|
||||
Use this script as template:
|
||||
|
||||
```
|
||||
#!/bin/bash
|
||||
|
||||
echo "Update Wordrpress"
|
||||
docker-compose exec wordpress wp theme update --all --path="/app/wordpress/"
|
||||
docker-compose exec wordpress wp plugin update --all --path="/app/wordpress/"
|
||||
docker-compose exec wordpress wp core update --path="/app/wordpress/"
|
||||
```
|
||||
|
||||
## Backups
|
||||
|
||||
docker-compose exec db mysqldump --database <MYSQL_DATABASE> > <custom_path>/<dump>.sql
|
||||
|
||||
## Restore
|
||||
|
||||
Database restore, like this examples:
|
||||
|
||||
$ cat <dump>.sql | docker-compose exec db mysql -u <db_user> -p<db_pass> <database>
|
||||
|
||||
Data restore, bulk to volume directory, like:
|
||||
|
||||
$ rsync -avz <backup_wordpress_dir> /var/lib/docker/volumes/<docker_wordpress_volume>/_data/wordpress/
|
||||
|
38
config/nginx-wordpress.conf
Normal file
38
config/nginx-wordpress.conf
Normal file
@ -0,0 +1,38 @@
|
||||
server {
|
||||
listen 443 ssl default_server;
|
||||
include snippets/snakeoil.conf;
|
||||
|
||||
server_name _;
|
||||
|
||||
root /app/wordpress;
|
||||
index index.php index.html;
|
||||
|
||||
client_max_body_size 25M;
|
||||
|
||||
location ~ /\. {
|
||||
deny all;
|
||||
}
|
||||
|
||||
location ~* /(?:uploads|files)/.*\.php$ {
|
||||
deny all;
|
||||
}
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /index.php?$args ;
|
||||
}
|
||||
|
||||
location ~ \.php$ {
|
||||
try_files $uri =404;
|
||||
include fastcgi_params;
|
||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||
fastcgi_split_path_info ^(.+\.php)(/.+)$;
|
||||
fastcgi_index index.php;
|
||||
fastcgi_read_timeout 300;
|
||||
fastcgi_send_timeout 300;
|
||||
fastcgi_pass wordpress:9000;
|
||||
}
|
||||
|
||||
access_log /app/log/wordpress.access.log;
|
||||
error_log /app/log/wordpress.error.log;
|
||||
}
|
||||
|
61
config/nginx.conf
Normal file
61
config/nginx.conf
Normal file
@ -0,0 +1,61 @@
|
||||
worker_processes auto;
|
||||
pid /run/nginx/nginx.pid;
|
||||
error_log stderr info;
|
||||
daemon off;
|
||||
master_process off;
|
||||
|
||||
include /etc/nginx/modules-enabled/*.conf;
|
||||
|
||||
|
||||
events {
|
||||
worker_connections 768;
|
||||
# multi_accept on;
|
||||
}
|
||||
|
||||
http {
|
||||
|
||||
##
|
||||
# Basic Settings
|
||||
##
|
||||
|
||||
sendfile on;
|
||||
tcp_nopush on;
|
||||
tcp_nodelay on;
|
||||
keepalive_timeout 65;
|
||||
types_hash_max_size 2048;
|
||||
server_tokens off;
|
||||
|
||||
server_names_hash_bucket_size 128;
|
||||
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
##
|
||||
# SSL Settings
|
||||
##
|
||||
|
||||
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
|
||||
ssl_prefer_server_ciphers on;
|
||||
|
||||
##
|
||||
# Logging Settings
|
||||
##
|
||||
|
||||
access_log /dev/stdout;
|
||||
|
||||
##
|
||||
# Gzip Settings
|
||||
##
|
||||
|
||||
gzip on;
|
||||
gzip_disable "msie6";
|
||||
|
||||
##
|
||||
# Virtual Host Configs
|
||||
##
|
||||
|
||||
include /etc/nginx/conf.d/*.conf;
|
||||
#include /etc/nginx/sites-enabled/*;
|
||||
}
|
||||
|
||||
|
23
config/php-fpm-wordpress.conf
Normal file
23
config/php-fpm-wordpress.conf
Normal file
@ -0,0 +1,23 @@
|
||||
[www]
|
||||
|
||||
user = www-data
|
||||
group = www-data
|
||||
listen = 9000
|
||||
|
||||
listen.owner = www-data
|
||||
listen.group = www-data
|
||||
|
||||
pm = dynamic
|
||||
pm.max_children = 5
|
||||
pm.start_servers = 2
|
||||
pm.min_spare_servers = 1
|
||||
pm.max_spare_servers = 3
|
||||
|
||||
access.log = /app/log/access.log
|
||||
catch_workers_output = yes
|
||||
;php_admin_value[error_log] = /app/log/php-fpm.log
|
||||
;php_admin_flag[log_errors] = on
|
||||
php_flag[display_errors] = off
|
||||
php_admin_value[allow_url_fopen] = off
|
||||
php_admin_value[upload_max_filesize] = 50M
|
||||
php_admin_value[post_max_size] = 50M
|
@ -1,32 +1,50 @@
|
||||
version: '3'
|
||||
|
||||
volumes:
|
||||
db:
|
||||
data:
|
||||
version: '2.4'
|
||||
|
||||
services:
|
||||
db:
|
||||
image: mariadb
|
||||
restart: "no"
|
||||
user: 1000:1000
|
||||
restart: always
|
||||
volumes:
|
||||
- db:/var/lib/mysql
|
||||
- ./db:/var/lib/mysql
|
||||
environment:
|
||||
MYSQL_DATABASE: ahum_backend
|
||||
MYSQL_USER: ahum_backend
|
||||
MYSQL_RANDOM_ROOT_PASSWORD: '1'
|
||||
MYSQL_PASSWORD: Bmu6SJCc8ztGScoC2sk4i
|
||||
- MYSQL_DATABASE
|
||||
- MYSQL_USER
|
||||
- MYSQL_RANDOM_ROOT_PASSWORD
|
||||
- MYSQL_PASSWORD
|
||||
|
||||
wordpress:
|
||||
image: registry.audio-lab.org/wordpress
|
||||
build: .
|
||||
user: 1000:1000
|
||||
depends_on:
|
||||
- db
|
||||
volumes:
|
||||
- data:/app/wordpress
|
||||
restart: "no"
|
||||
- ./data:/app
|
||||
restart: always
|
||||
links:
|
||||
- db
|
||||
environment:
|
||||
- MYSQL_DATABASE
|
||||
- MYSQL_USER
|
||||
- MYSQL_PASSWORD
|
||||
- MYSQL_HOST
|
||||
- WP_USER
|
||||
- WP_PASS
|
||||
- WP_EMAIL
|
||||
- WP_TITLE
|
||||
- WP_URL
|
||||
|
||||
|
||||
nginx:
|
||||
build: ./nginx/
|
||||
image: registry.sindominio.net/nginx
|
||||
ports:
|
||||
- 127.0.0.1:8180:443
|
||||
- ${NGINX_PORT}:443
|
||||
volumes:
|
||||
- ./nginx.conf:/etc/nginx/conf.d/default.conf:ro
|
||||
- data:/app/wordpress
|
||||
restart: "no"
|
||||
#- ./nginx.conf:/etc/nginx/conf.d/default.conf:ro
|
||||
- ./config/nginx.conf:/etc/nginx/nginx.conf:ro
|
||||
- ./config/nginx-wordpress.conf:/etc/nginx/conf.d/wordpress.conf:ro
|
||||
- ./data:/app
|
||||
restart: always
|
||||
links:
|
||||
- wordpress
|
||||
|
@ -1,33 +0,0 @@
|
||||
version: '3'
|
||||
|
||||
volumes:
|
||||
db:
|
||||
data:
|
||||
|
||||
services:
|
||||
db:
|
||||
image: mariadb
|
||||
restart: always
|
||||
volumes:
|
||||
- db:/var/lib/mysql
|
||||
environment:
|
||||
MYSQL_DATABASE: wordpress
|
||||
MYSQL_USER: wordpress
|
||||
MYSQL_RANDOM_ROOT_PASSWORD: '1'
|
||||
MYSQL_PASSWORD: wordpress
|
||||
|
||||
wordpress:
|
||||
build: .
|
||||
volumes:
|
||||
- data:/app/wordpress
|
||||
restart: always
|
||||
|
||||
nginx:
|
||||
build: ./nginx/
|
||||
ports:
|
||||
- 8180:443
|
||||
volumes:
|
||||
- ./nginx.conf:/etc/nginx/conf.d/default.conf:ro
|
||||
volumes_from:
|
||||
- wordpress
|
||||
restart: always
|
59
entrypoint.sh
Executable file
59
entrypoint.sh
Executable file
@ -0,0 +1,59 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e;
|
||||
|
||||
export WORDPRESS_ROOT=/app/wordpress
|
||||
|
||||
install() {
|
||||
echo "Install Wordpress $WORDPRESS_ROOT"
|
||||
mkdir -p $WORDPRESS_ROOT
|
||||
cd $WORDPRESS_ROOT
|
||||
wp core download
|
||||
config
|
||||
}
|
||||
|
||||
install_themes() {
|
||||
echo "Install Themes"
|
||||
cp -R /tmp/wordpress/themes/* /app/wordpress/wp-content/themes/
|
||||
}
|
||||
|
||||
install_plugins() {
|
||||
echo "Install Plugins"
|
||||
cp -R /tmp/wordpress/plugins/* /app/wordpress/wp-content/plugins/
|
||||
}
|
||||
|
||||
config() {
|
||||
echo "Config Wordpress $WORDPRESS_ROOT"
|
||||
cd $WORDPRESS_ROOT
|
||||
echo "Create Config"
|
||||
wp config create --dbname=$MYSQL_DATABASE --dbuser=$MYSQL_USER --dbpass=$MYSQL_PASSWORD --dbhost=$MYSQL_HOST --locale=es_ES
|
||||
echo "Install Worpdress"
|
||||
if ! wp core is-installed; then
|
||||
wp core install --url="$WP_URL" --title="$WP_TITLE" --admin_user="$WP_USER" --admin_password="$WP_PASS" --admin_email="$WP_EMAIL" --path="/app/wordpress/"
|
||||
fi
|
||||
}
|
||||
|
||||
update() {
|
||||
echo "Update Wordpress"
|
||||
cd $WORDPRESS_ROOT
|
||||
#https://make.wordpress.org/cli/handbook/
|
||||
wp core update --path="/app/wordpress/"
|
||||
wp plugin update --all --path="/app/wordpress/"
|
||||
wp theme update --all --path="/app/wordpress/"
|
||||
}
|
||||
|
||||
mkdir -p /app/log/
|
||||
|
||||
[ -d /app/wordpress ] || install
|
||||
[ -f /app/wordpress/wp-config.php ] || config
|
||||
|
||||
# WP-CLI install
|
||||
# https://www.cloudways.com/blog/install-wordpress-using-wp-cli/
|
||||
|
||||
update
|
||||
install_themes
|
||||
install_plugins
|
||||
|
||||
echo "Starting Wordpress"
|
||||
|
||||
exec $@
|
14
env.sample
Normal file
14
env.sample
Normal file
@ -0,0 +1,14 @@
|
||||
MYSQL_DATABASE=wordpress
|
||||
MYSQL_USER=wordpress
|
||||
MYSQL_RANDOM_ROOT_PASSWORD=1
|
||||
MYSQL_PASSWORD=wordpress
|
||||
MYSQL_HOST=db
|
||||
|
||||
NGINX_PORT=8443
|
||||
USER_GROUP=1000:1000
|
||||
|
||||
WP_USER=admin
|
||||
WP_PASS=admin
|
||||
WP_EMAIL=real@mail.org
|
||||
WP_TITLE=Wordpress Title
|
||||
WP_URL=http://docker:8180
|
@ -1,3 +0,0 @@
|
||||
FROM nginx:alpine
|
||||
RUN apk add openssl
|
||||
RUN openssl req -x509 -nodes -days 365 -subj "/C=CA/ST=QC/O=Company, Inc./CN=mydomain.com" -addext "subjectAltName=DNS:mydomain.com" -newkey rsa:2048 -keyout /etc/ssl/private/nginx.key -out /etc/ssl/certs/nginx.crt
|
@ -1,14 +0,0 @@
|
||||
[wordpress]
|
||||
|
||||
user = wordpress
|
||||
group = wordpress
|
||||
listen = 9000
|
||||
|
||||
listen.owner = wordpress
|
||||
listen.group = wordpress
|
||||
|
||||
pm = dynamic
|
||||
pm.max_children = 5
|
||||
pm.start_servers = 2
|
||||
pm.min_spare_servers = 1
|
||||
pm.max_spare_servers = 3
|
Loading…
Reference in New Issue
Block a user