Compare commits

..

4 Commits

Author SHA1 Message Date
faba4dfe92 Fix: Copy themes and plugins 2022-12-09 20:52:24 +01:00
9da9291695 Update: Simplify wordpress install 2022-12-09 03:40:02 +01:00
0ad95330d8 Actualizar 'Dockerfile'
ADD wordpress home to /app/wordpress && comment
2021-05-05 12:51:28 +00:00
Siroco
a623668c17 Documentation 2021-03-17 02:18:47 +01:00
13 changed files with 302 additions and 101 deletions

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
data
db
.env

View File

@ -1,42 +1,36 @@
FROM debian:bullseye-slim as build FROM debian:stable-slim
RUN apt-get update && \ RUN apt-get update && \
apt-get -qy install \ apt-get -qy install \
php-fpm php-mysql php-curl php-gd php-mbstring php-xml php-xmlrpc php-soap php-intl php-zip \ php-fpm php-mysql php-curl php-gd php-mbstring php-xml php-xmlrpc php-soap php-intl php-zip php-redis \
sudo wget curl ca-certificates&&\ wget sed curl tar ca-certificates less \
mariadb-client && \
apt-get clean apt-get clean
RUN useradd wordpress
COPY wordpress.conf /etc/php/7.4/fpm/pool.d/www.conf COPY config/php-fpm-wordpress.conf /tmp/www.conf
RUN mkdir /run/php/
#RUN mkdir logs
#USER wordpress RUN PHP_VERSION=$(php --version | head -n 1 | cut -f2 -d" " | cut -f1,2 -d".") && \
WORKDIR app cp /tmp/www.conf /etc/php/$PHP_VERSION/fpm/pool.d/www.conf && \
RUN wget -O wordpress.tar.gz "https://wordpress.org/latest.tar.gz" mkdir /run/php/ && \
RUN wget https://wordpress.org/latest.tar.gz ln -s /usr/sbin/php-fpm$PHP_VERSION /usr/sbin/php-fpm && \
RUN tar -xzf wordpress.tar.gz sed -i '/^error_log/cerror_log = /app/log/php-fpm.log' /etc/php/$PHP_VERSION/fpm/php-fpm.conf && \
RUN rm latest.tar.gz sed -i '/^pid/cpid = /app/log/php-fpm.pid' /etc/php/$PHP_VERSION/fpm/php-fpm.conf
#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 curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar WORKDIR /app
RUN chmod +x wp-cli.phar
RUN mv wp-cli.phar wp
## ESTO EN UN CRON DAILY RUN curl -s -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar && \
#RUN sudo -u wordpress /app/wp theme update --all --path="/app/wordpress/" chmod +x wp-cli.phar && \
#RUN ./wp plugin update --all --path="/app/wordpress/" mv wp-cli.phar /usr/local/bin/wp
#RUN ./wp core update --all --path="/app/wordpress/"
#USER root ADD wordpress /tmp/wordpress
ADD entrypoint.sh /entrypoint.sh
EXPOSE 9000 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"]

View File

@ -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 $ docker-compose build
# Run ## Run
$ docker-compose up -d $ 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/

View 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
View 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/*;
}

View 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

View File

@ -1,32 +1,50 @@
version: '3' version: '2.4'
volumes:
db:
data:
services: services:
db: db:
image: mariadb image: mariadb
restart: "no" user: 1000:1000
restart: always
volumes: volumes:
- db:/var/lib/mysql - ./db:/var/lib/mysql
environment: environment:
MYSQL_DATABASE: ahum_backend - MYSQL_DATABASE
MYSQL_USER: ahum_backend - MYSQL_USER
MYSQL_RANDOM_ROOT_PASSWORD: '1' - MYSQL_RANDOM_ROOT_PASSWORD
MYSQL_PASSWORD: Bmu6SJCc8ztGScoC2sk4i - MYSQL_PASSWORD
wordpress: wordpress:
image: registry.audio-lab.org/wordpress
build: . build: .
user: 1000:1000
depends_on:
- db
volumes: volumes:
- data:/app/wordpress - ./data:/app
restart: "no" restart: always
links:
- db
environment:
- MYSQL_DATABASE
- MYSQL_USER
- MYSQL_PASSWORD
- MYSQL_HOST
- WP_USER
- WP_PASS
- WP_EMAIL
- WP_TITLE
- WP_URL
nginx: nginx:
build: ./nginx/ image: registry.sindominio.net/nginx
ports: ports:
- 127.0.0.1:8180:443 - ${NGINX_PORT}:443
volumes: volumes:
- ./nginx.conf:/etc/nginx/conf.d/default.conf:ro #- ./nginx.conf:/etc/nginx/conf.d/default.conf:ro
- data:/app/wordpress - ./config/nginx.conf:/etc/nginx/nginx.conf:ro
restart: "no" - ./config/nginx-wordpress.conf:/etc/nginx/conf.d/wordpress.conf:ro
- ./data:/app
restart: always
links:
- wordpress

View File

@ -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
View 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
View 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

View File

@ -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

View File

@ -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