Update: SSH/WPCLI/Worpress/...

This commit is contained in:
root 2022-02-26 19:43:43 +00:00
commit d5b26c7f34
7 changed files with 316 additions and 0 deletions

26
Dockerfile Normal file
View File

@ -0,0 +1,26 @@
FROM registry.sindominio.net/php-fpm
RUN apt-get update && \
apt-get -qy install \
php-mysql php-curl php-gd php-mbstring php-xml php-xmlrpc php-soap php-intl php-zip \
wget less tar curl ca-certificates &&\
apt-get clean
RUN mkdir -p /app/
WORKDIR /app
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
COPY ./config/wp-config-sample.php /tmp/wp-config-sample.php
COPY ./entrypoint.sh /entrypoint.sh
VOLUME /app/
EXPOSE 9000
ENTRYPOINT [ "/bin/sh", "/entrypoint.sh" ]
CMD ["/usr/sbin/php-fpm","--nodaemonize"]

46
README.md Normal file
View File

@ -0,0 +1,46 @@
Simple custom template for a clean Wordpress installation.
# Config
Create data directories:
```
$ mkdir db data
```
Database credentials may edit on ENVIRONMENT on docker-compose.yml or user _.env_ file:
```
$ cp .env.sample .env
$ vim .env
```
# Add SSH submodule
```
$ git submodule add https://git.audio-lab.org/lrullo/sshd.git sshd
```
# Build and Pull images
$ docker-compose pull
$ docker-compose build
# Run
$ docker-compose up -d
# Auto update Wordpress
User crontab on your hoster server.
Use this script as template:
```
#!/bin/bash
echo "Update Wordrpress"
docker exec -it docker-wordpress sudo -u wordpress -i -- /app/wp theme update --all --path="/app/wordpress/"
docker exec -it docker-wordpress_1 sudo -u wordpress -i -- /app/wp plugin update --all --path="/app/wordpress/"
docker exec -it docker-wordpress sudo -u wordpress -i -- /app/wp core update --path="/app/wordpress/"
```

59
config/nginx.conf Normal file
View File

@ -0,0 +1,59 @@
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/*;
}

88
config/wordpress.conf Normal file
View File

@ -0,0 +1,88 @@
server {
listen 80;
root /app/wordpress/;
index index.php;
server_name _;
access_log /var/log/nginx/access.log;
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_pass wordpress:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
set $path_info $fastcgi_path_info;
fastcgi_param PATH_INFO $path_info;
fastcgi_param REMOTE_ADDR $http_x_real_ip;
fastcgi_read_timeout 300;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
access_log off;
log_not_found off;
}
}
server {
listen 443 ssl default_server;
include snippets/snakeoil.conf;
root /app/wordpress/;
index index.php index.html;
server_name _;
access_log /var/log/nginx/access.log;
location / {
try_files $uri $uri/ /index.php?$args ;
}
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_pass wordpress:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
set $path_info $fastcgi_path_info;
fastcgi_param PATH_INFO $path_info;
fastcgi_param REMOTE_ADDR $http_x_real_ip;
fastcgi_read_timeout 300;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
access_log off;
log_not_found off;
}
}

View File

@ -0,0 +1,16 @@
<?php
define( 'DB_NAME', 'MYSQL_DATABASE' );
define( 'DB_USER', 'MYSQL_USER' );
define( 'DB_PASSWORD', 'MYSQL_PASSWORD' );
define( 'DB_HOST', 'MYSQL_HOST' );
define( 'DB_CHARSET', 'utf8' );
define( 'DB_COLLATE', '' );
$table_prefix = 'wp_';
define( 'WP_DEBUG', false );
if ( ! defined( 'ABSPATH' ) ) {
define( 'ABSPATH', __DIR__ . '/' );
}
require_once ABSPATH . 'wp-settings.php';

48
docker-compose.yml Normal file
View File

@ -0,0 +1,48 @@
version: '3'
services:
db:
image: mariadb
restart: always
user: ${USER_GROUP}
volumes:
- ./db:/var/lib/mysql
environment:
MYSQL_DATABASE: ${MYSQL_DATABASE}
MYSQL_USER: ${MYSQL_USER}
MYSQL_RANDOM_ROOT_PASSWORD: '1'
MYSQL_PASSWORD: ${MYSQL_PASSWORD}
wordpress:
build: .
user: ${USER_GROUP}
volumes:
- ./data:/app
restart: always
environment:
MYSQL_DATABASE: ${MYSQL_DATABASE}
MYSQL_USER: ${MYSQL_USER}
MYSQL_HOST: ${MYSQL_HOST}
MYSQL_PASSWORD: ${MYSQL_PASSWORD}
nginx:
image: registry.sindominio.net/nginx
ports:
- ${NGINX_PORT_HTTP}:80
- ${NGINX_PORT_HTTPS}:443
volumes:
- ./config/nginx.conf:/etc/nginx/nginx.conf:ro
- ./config/wordpress.conf:/etc/nginx/conf.d/wordpress.conf:ro
- ./data:/app
restart: always
ssh:
build: ./sshd/
environment:
SSH_USER: ${SSH_USER}
SSH_PASS: ${SSH_PASSWORD}
ports:
- ${SSH_PORT}:22
volumes:
- ./data:/app
restart: always

33
entrypoint.sh Normal file
View File

@ -0,0 +1,33 @@
#!/bin/bash
set -e;
install() {
cd /app
wget --quiet https://wordpress.org/latest.tar.gz
tar -xzf latest.tar.gz
rm latest.tar.gz
}
config() {
if [ -n $MYSQL_DATABASE ]; then sed -i "s:MYSQL_DATABASE:$MYSQL_DATABASE:" /app/wordpress/wp-config.php; fi
if [ -n $MYSQL_USER ]; then sed -i "s:MYSQL_USER:$MYSQL_USER:" /app/wordpress/wp-config.php; fi
if [ -n $MYSQL_PASSWORD ]; then sed -i "s:MYSQL_PASSWORD:$MYSQL_PASSWORD:" /app/wordpress/wp-config.php; fi
if [ -n $MYSQL_HOST ]; then sed -i "s:MYSQL_HOST:$MYSQL_HOST:" /app/wordpress/wp-config.php; fi
SALT_KEYS=$(curl -s https://api.wordpress.org/secret-key/1.1/salt)
echo $SALT_KEYS >> /app/wordpress/wp-config.php;
}
create_wpconfig() {
if [ -n /app/wordpress/wp-config.php ]; then cp /tmp/wp-config-sample.php /app/wordpress/wp-config.php; fi
}
install
create_wpconfig
config
echo "Starting Wordpress"
exec $@