Compare commits
12 Commits
ef3feef634
...
main
Author | SHA1 | Date | |
---|---|---|---|
5794d7f9ce
|
|||
e21080fae8
|
|||
b0d12b11f3
|
|||
3e92ae47a5 | |||
9b2f5eec60 | |||
8870e4b837 | |||
cf00cc81da | |||
bf5ecd7b7c | |||
b39b5ac713 | |||
4ccb5b9a4e | |||
79047e02e5 | |||
a0c19b759b |
21
.drone.yml
21
.drone.yml
@ -2,17 +2,32 @@
|
||||
kind: pipeline
|
||||
name: deploy main branch to live site
|
||||
steps:
|
||||
- name: php syntax check
|
||||
image: php:8.3.7-cli
|
||||
commands:
|
||||
- for f in $(find /drone -name '*.php'); do php -l "$f"; done
|
||||
# If a custom block is in use, uncomment this (and make sure package.json
|
||||
# includes `scripts.build`, and change the `depends_on` below
|
||||
# - name: compile custom block
|
||||
# image: node:18.18.2
|
||||
# commands:
|
||||
# - npm install
|
||||
# - npm run build
|
||||
# depends_on:
|
||||
# - php syntax check
|
||||
- name: docker cp deploy
|
||||
image: git.coopcloud.tech/coop-cloud/docker-cp-deploy:latest
|
||||
settings:
|
||||
host: server.example.com
|
||||
service: wordpress_example_com_app
|
||||
source: wp-content/themes/theme
|
||||
exec_pre: rm -rf /var/www/html/wp-content/themes/theme/*
|
||||
service: ${REPO_NAME_SNAKE}
|
||||
source: wp-content/themes/${REPO_NAME}
|
||||
exec_pre: rm -rf /var/www/html/wp-content/themes/${REPO_NAME}/*
|
||||
exec: composer install
|
||||
dest: /var/www/html/
|
||||
deploy_key:
|
||||
from_secret: drone_ssh_server.example.com
|
||||
depends_on:
|
||||
- php syntax check
|
||||
when:
|
||||
branch:
|
||||
- main
|
||||
|
@ -1,7 +1,10 @@
|
||||
##############################################################################
|
||||
# REQUIRED SETTINGS (you will need these) #
|
||||
##############################################################################
|
||||
|
||||
|
||||
# What username should `set_local_password` operate on?
|
||||
USERNAME=admin
|
||||
|
||||
##############################################################################
|
||||
# COMMON SETTINGS (you may need these) #
|
||||
##############################################################################
|
||||
@ -33,3 +36,6 @@ SITE_URL=$REPO_NAME_SNAKE.tld
|
||||
|
||||
# Multi-site config
|
||||
#WORDPRESS_CONFIG_EXTRA="define('MULTISITE', true); define('SUBDOMAIN_INSTALL', true); define('DOMAIN_CURRENT_SITE', 'frms.localhost'); define('PATH_CURRENT_SITE', '/'); define('SITE_ID_CURRENT_SITE', 1); define('BLOG_ID_CURRENT_SITE', 1); define('SUNRISE', true);"
|
||||
|
||||
# Use composer for plugin installation
|
||||
#USE_COMPOSER=1
|
||||
|
@ -1,3 +1,4 @@
|
||||
.drone.yml
|
||||
|
||||
.env.sample
|
||||
.gitignore
|
||||
README.md
|
||||
|
4
.gitignore
vendored
4
.gitignore
vendored
@ -1,6 +1,8 @@
|
||||
/.env
|
||||
|
||||
/wp-content/twenty*
|
||||
/wp-content/**
|
||||
# Add an exception here for any custom plugins or themes to be included, e.g.
|
||||
#!/wp-content/themes/${REPO_NAME_SNAKE}
|
||||
|
||||
/data/**
|
||||
!/data/.gitkeep
|
||||
|
15
README.md
15
README.md
@ -1,15 +1,26 @@
|
||||
A template for Autonomic Wordpress projects, including local set-up, and auto-deployment.
|
||||
|
||||
To use it:
|
||||
# Usage
|
||||
1. Make a new repository, using this as a template
|
||||
2. Remove this notice from `README.md` (everything until the `---`)
|
||||
3. Create and deploy a Co-op Cloud Wordpress app
|
||||
4. Edit `.env.sample` to set `SITE_URL` (and customise `PROJECT_NAME`, if
|
||||
needed)
|
||||
- Change USERNAME to whatever the wordpress admin username is / should be
|
||||
- Set SITE_URL to the live site URL
|
||||
- Set PROJECT_NAME to some identifier for the project
|
||||
5. Make sure `.drone.yml` has the right settings for the server you'd like to
|
||||
deploy to
|
||||
deploy
|
||||
- Change host to the FQDN of the host, likely smol-wp.autonomic.zone
|
||||
- Set service to the docker service name, usually <app_name_snake_case>_app so like display_distribute_com_app
|
||||
- Update source and exec_pre to the path to the theme
|
||||
- Comment exec: composer install if composer isn't in use
|
||||
- Set `deploy_key: from_secret:` to the secret name of the SSH key to access the server. this requires logging into drone as autonomic admin, then checking "organisation secrets" on the repo settings page of any repo in the same org. or you can use drone CLI and do drone orgsecret ls
|
||||
6. Add any custom plugins / themes to `wp-content`
|
||||
- Copying / moving files into the repo in wp-content, and possibly / probably excluding them from .gitignore
|
||||
7. "Activate" this repository in Drone
|
||||
- e.g. click "activate repository" here https://drone.autonomic.zone/autonomic-cooperative/display-distribute/settings
|
||||
8. Commit to the repo to test and monitor the drone interface to troubleshoot
|
||||
|
||||
---
|
||||
|
||||
|
@ -3,12 +3,13 @@ version: "3"
|
||||
|
||||
services:
|
||||
wordpress:
|
||||
image: "wordpress:6.2.0"
|
||||
image: "wordpress:6.5.3"
|
||||
ports:
|
||||
- "80:80"
|
||||
dns: 4.2.2.4
|
||||
volumes:
|
||||
- "./entrypoint.sh:/usr/local/bin/entrypoint.sh:z"
|
||||
- "./mailhog-smtp.php:/var/www/html/wp-content/mu-plugins/mailhog-smtp.php:z"
|
||||
- "./wp-content:/var/www/html/wp-content/:z"
|
||||
- "./composer.json:/var/www/html/composer.json:z"
|
||||
- "./composer.lock:/var/www/html/composer.lock:z"
|
||||
|
@ -8,7 +8,7 @@ if [ -n "$PHP_EXTENSIONS" ]; then
|
||||
done
|
||||
fi
|
||||
|
||||
if ! id -u "user" >/dev/null ; then
|
||||
if ! id -u "user" >/dev/null 2>&1; then
|
||||
useradd -u 1000 -m user
|
||||
mkdir /var/www/html/vendor
|
||||
chown -R user:user /var/www/html/vendor
|
||||
@ -23,12 +23,12 @@ if [ ! -x /usr/local/bin/wp ]; then
|
||||
chmod +x /usr/local/bin/wp
|
||||
fi
|
||||
|
||||
if [ ! -x /usr/local/bin/composer ]; then
|
||||
if [ -n "$USE_COMPOSER" ] && [ ! -x /usr/local/bin/composer ]; then
|
||||
mkdir -p /var/www/.composer
|
||||
chown user:user /var/www/.composer
|
||||
|
||||
curl https://getcomposer.org/installer -o /tmp/composer-setup.php
|
||||
php -r "if (hash_file('sha384', '/tmp/composer-setup.php') === 'e21205b207c3ff031906575712edab6f13eb0b361f2085f1f1237b7126d785e826a450292b6cfd1d64d92e6563bbde02') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
|
||||
php -r "if (hash_file('sha384', '/tmp/composer-setup.php') === 'dac665fdc30fdd8ec78b38b9800061b4150413ff2e3b6f88543c636f7cd84f6db9189d43a81e5503cda447da73c7e5b6') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
|
||||
php /tmp/composer-setup.php
|
||||
rm /tmp/composer-setup.php
|
||||
|
||||
|
21
mailhog-smtp.php
Normal file
21
mailhog-smtp.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
// Send outgoing mails through Mailhog
|
||||
|
||||
function action_wp_mail_failed($wp_error) {
|
||||
print_r($wp_error, true);
|
||||
exit;
|
||||
}
|
||||
add_action('wp_mail_failed', 'action_wp_mail_failed', 10, 1);
|
||||
|
||||
add_action('phpmailer_init', function ($phpmailer) {
|
||||
$phpmailer->isSMTP();
|
||||
$phpmailer->SMTPAuth = false;
|
||||
$phpmailer->SMTPSecure = false;
|
||||
$phpmailer->SMTPAutoTLS = false;
|
||||
$phpmailer->Host = "mailhog";
|
||||
$phpmailer->Port = 1025;
|
||||
$phpmailer->From = "noreply@radhr.localhost";
|
||||
$phpmailer->FromName = "noreply@radhr.localhost";
|
||||
$phpmailer->Username = null;
|
||||
$phpmailer->Password = null;
|
||||
});
|
6
makefile
6
makefile
@ -112,7 +112,7 @@ uploads_load:
|
||||
|
||||
## Download database from dev site
|
||||
db_fetch:
|
||||
$(ABRA) app run $(SITE_URL) db bash -c 'mysqldump -u root -p"$$(cat /run/secrets/db_root_password)" wordpress' | gzip > data/dbdump.sql.gz
|
||||
$(ABRA) app run $(SITE_URL) db bash -c 'mariadb-dump -u root -p"$$(cat /run/secrets/db_root_password)" wordpress' | gzip > data/dbdump.sql.gz
|
||||
|
||||
## Load latest database from ~/.abra/backups
|
||||
db_load:
|
||||
@ -121,11 +121,9 @@ db_load:
|
||||
## Replace site URL
|
||||
fix_url:
|
||||
$(_DOCKER_COMPOSE) exec -u user wordpress wp --url=https://$(SITE_URL) search-replace --all-tables-with-prefix 'https://$(SITE_URL)' 'http://$(PROJECT_NAME).localhost'
|
||||
$(_DOCKER_COMPOSE) exec -u user wordpress wp --url=https://$(SITE_URL) search-replace --all-tables-with-prefix '$(SITE_URL)' '$(PROJECT_NAME).localhost'
|
||||
$(_DOCKER_COMPOSE) exec -u user wordpress wp --url=https://$(SITE_URL) search-replace --all-tables-with-prefix 'fashionrevolution.org' '$(PROJECT_NAME).localhost'
|
||||
|
||||
set_local_password:
|
||||
$(_DOCKER_COMPOSE) exec -u user wordpress wp user update admin --user_pass=password
|
||||
$(_DOCKER_COMPOSE) exec -u user wordpress wp user update $(USERNAME) --user_pass=password
|
||||
|
||||
db_pull: db_fetch db_load fix_url
|
||||
|
||||
|
Reference in New Issue
Block a user