Compare commits

..

No commits in common. "84f548938892e3c6e6b15710e193a87a520a82c0" and "40ccf105e1b12554bc890654474fd794a6d39ad2" have entirely different histories.

3 changed files with 16 additions and 29 deletions

View File

@ -25,7 +25,7 @@ export _wp_plugins_active="elementor wp-mail-smtp gdpr-cookie-compliance regener
export _docker_user="ray" export _docker_user="ray"
export _remote_host="wp-stack-five" export _remote_host="wp-stack-four"
export _domain="wptest.isnet.uk" export _domain="wptest.isnet.uk"
export _docker_base_dir="/var/docker" export _docker_base_dir="/var/docker"
export _mysql_root_passwd="db" export _mysql_root_passwd="db"

View File

@ -81,7 +81,7 @@ http {
location ~ ~$ { access_log off; log_not_found off; deny all; } location ~ ~$ { access_log off; log_not_found off; deny all; }
location /wp-content { location /wp-content {
root /usr/share/nginx/html; root /usr/share/nginx/html/wp-content;
expires 7d; expires 7d;
add_header Cache-Control "public"; add_header Cache-Control "public";
} }

View File

@ -14,7 +14,6 @@ echo "MYSQL_DATABASE=wordpress" >> .env
$_ssh_cmd "mkdir -p $_docker_dir/wordpress" $_ssh_cmd "mkdir -p $_docker_dir/wordpress"
echo "Copying files ..."
scp -r production/config "$_scp_to_base"/config scp -r production/config "$_scp_to_base"/config
scp production/Dockerfile "$_scp_to_base"/Dockerfile scp production/Dockerfile "$_scp_to_base"/Dockerfile
scp production/entrypoint.sh "$_scp_to_base"/entrypoint.sh scp production/entrypoint.sh "$_scp_to_base"/entrypoint.sh
@ -24,19 +23,15 @@ scp production/docker-compose.yml "$_scp_to_base"/docker-compose.yml
scp wordpress.tar.gz "$_scp_to_base"/wordpress.tar.gz scp wordpress.tar.gz "$_scp_to_base"/wordpress.tar.gz
$_ssh_cmd "tar -xf $_docker_dir/wordpress.tar.gz -C $_docker_dir/wordpress && rm $_docker_dir/wordpress.tar.gz" $_ssh_cmd "tar -xf $_docker_dir/wordpress.tar.gz -C $_docker_dir/wordpress && rm $_docker_dir/wordpress.tar.gz"
echo "Configuring files ..."
$_ssh_cmd "sed -i 's/__HOST__/$_remote_host/g' $_docker_dir/config/nginx.conf" $_ssh_cmd "sed -i 's/__HOST__/$_remote_host/g' $_docker_dir/config/nginx.conf"
# TODO make this more robust than just substituting localhost # TODO make this more robust than just changing any old localhost
$_ssh_cmd "sed -i 's/localhost/$_remote_host-mysql/g' $_docker_dir/wordpress/wp-config.php" $_ssh_cmd "sed -i 's/localhost/$_remote_host-mysql/g' $_docker_dir/wordpress/wp-config.php"
$_ssh_cmd "chown -R $_docker_user: $_docker_dir" $_ssh_cmd "chown -R $_docker_user: $_docker_dir"
# The 82 comes from the Dockerfile addgroup and adduser commands
$_ssh_cmd "chown -R 82:82 $_docker_dir/wordpress"
echo "Starting containers ..."
$_ssh_cmd "cd $_docker_dir && docker-compose up -d --build" $_ssh_cmd "cd $_docker_dir && docker-compose up -d --build"
# TODO - need to wait for mysql to initialise # TODO - need to wait for mysql to initialise
# temporary solution # temporary
echo "waiting for mysql to initialise ..." echo "waiting for mysql to initialise ..."
sleep 10 sleep 10
echo "still waiting for mysql to initialise ..." echo "still waiting for mysql to initialise ..."
@ -44,31 +39,23 @@ sleep 10
echo "waiting a little bit longer for mysql to initialise ..." echo "waiting a little bit longer for mysql to initialise ..."
sleep 5 sleep 5
echo "Configuring WordPress ..."
# TODO does docker always assign ips in range 172.% ???? # TODO does docker always assign ips in range 172.% ????
# TODO - sort this mess out - use functions or something
_ssh_shell_cmd='echo "GRANT ALL PRIVILEGES ON wordpress."*" TO \"wordpress\"@\"172.%\" IDENTIFIED BY \"wordpress\";" | mysql -uroot -pdb' _ssh_shell_cmd='echo "GRANT ALL PRIVILEGES ON wordpress."*" TO \"wordpress\"@\"172.%\" IDENTIFIED BY \"wordpress\";" | mysql -uroot -pdb'
# _ssh_shell_cmd='echo "'"$_mysql_cmd"'" | mysql -uroot -pdb'
echo "$_ssh_shell_cmd"
_cmd_docker_exec="cd $_docker_dir && docker exec -t $_remote_host-mysql /bin/sh -c '$_ssh_shell_cmd'" _cmd_docker_exec="cd $_docker_dir && docker exec -t $_remote_host-mysql /bin/sh -c '$_ssh_shell_cmd'"
echo "$_ssh_cmd $_cmd_docker_exec"
echo "$_ssh_cmd -- $_cmd_docker_exec"
$_ssh_cmd $_cmd_docker_exec $_ssh_cmd $_cmd_docker_exec
_cmd_wp="wp db import --dbuser=wordpress --dbpass=$_wp_db_passwd data.sql"
_cmd_docker_exec="cd $_docker_dir && docker exec -t $_remote_host-wordpress /bin/sh -c '$_cmd_wp'"
echo "$_ssh_cmd $_cmd_docker_exec"
$_ssh_cmd "$_cmd_docker_exec"
# TODO correct URLS _cmd_wp_import="wp db import --dbuser=wordpress --dbpass=$_wp_db_passwd data.sql"
# TODO move this into helper script _cmd_docker_exec="cd $_docker_dir && docker exec -t $_remote_host-wordpress /bin/sh -c '$_cmd_wp_import'"
# wp search-replace 'example.dev' 'example.com' --skip-columns=guid $_ssh_cmd "echo '$_wp_db_passwd' && $_cmd_docker_exec"
# Or, if you only want to change the option, you can do:
# wp option update home 'http://example.com'
# wp option update siteurl 'http://example.com';
_cmd_wp="wp search-replace '$_local_hostname.$_local_domain' '$_remote_host.$_domain' --skip-columns=guid"
_cmd_docker_exec="cd $_docker_dir && docker exec -t $_remote_host-wordpress /bin/sh -c '$_cmd_wp'"
echo "$_ssh_cmd $_cmd_docker_exec"
$_ssh_cmd "$_cmd_docker_exec"
# TODO ensure HTTP_X_FORWARDED_PROTO header is set in wp-config.php # set correct URLS
# ensure HTTP_X_FORWARDED_PROTO header is set in wp-config.php
# rm .env
# TODO 3m .env