refine and document prod flow

This commit is contained in:
sfigato 2024-07-31 23:30:29 +02:00
parent 22f36c7828
commit 5461aa9f3f
3 changed files with 69 additions and 6 deletions

View File

@ -1,6 +1,6 @@
DOCKER ?= docker
COMPOSE ?= docker compose
PUBLIC_URL ?= https://askar.abbiamoundominio.org
PUBLIC_URL ?= https://askar-association-ps.org
TMPDB_CONN = --host=127.0.0.1 --port=3307 --user=root --password=toor --ssl-verify-server-cert=FALSE
DUMP_CONN = -h 127.0.0.1 -P 3306 --user root --password=toor --ssl-verify-server-cert=FALSE
VERSIONED_DUMP = ./assets/db/dump.sql
@ -66,18 +66,18 @@ tmpdb-do-dump:
prepare-db: tmpdb-start tmpdb-do-dump tmpdb-stop
prepare-%:
tar czvf ./out/$*.tar.gz -C ./assets/wordpress/wp-content/$*
_prepare-%:
tar -C ./assets/wordpress/wp-content/ ./$* -czvf ./out/$*.tar.gz
prepare-data: prepare-uploads prepare-plugins
prepare-data: _prepare-uploads _prepare-plugins
prepare-export: prepare-db prepare-data
push-db:
cat $(PROD_DUMP) | ssh $(REMOTE_DB_HOST) mysql --user $(REMOTE_DB_USER) --password $$(age -d ./assets/admin.pass.age) $(REMOTE_DB_DATABASE)
cat $(PROD_DUMP) | ssh $(REMOTE_DB_HOST) mysql --user=$(REMOTE_DB_USER) --password=\'$$(age -d ./assets/db.prod.pass.age)\' $(REMOTE_DB_DATABASE)
_push-%:
cat ./out/$*.tar.gz | ssh $(REMOTE_WEB_HOST) tar zxvf -C $(REMOTE_WEB_ROOT) -
cat ./out/$*.tar.gz | ssh $(REMOTE_WEB_HOST) tar -C $(REMOTE_WEB_ROOT) -zxvf -
push-website: _push-uploads _push-plugins

View File

@ -34,3 +34,60 @@ The website will be a Wordpress with some customization. It will have the follow
## Dev
We use GNU make + docker
Set the environment variables as appropriate
```
export REMOTE_WEB_HOST=root@amelia.abbiamoundominio.org
export REMOTE_WEB_ROOT=/var/www/askar
export REMOTE_DB_HOST=root@comandantaramona.abbiamoundominio.org
export REMOTE_DB_USER=wordpress_askar
export REMOTE_DB_DATABASE=wordpress_askar
export PUBLIC_URL=https://askar-association-ps.org
```
### Pull content from production site
Pull the content (uploads+plugins)
```
make pull-website
```
Dump the remote db and pull it
```
make pull-db
```
### Push to production
Prepare the local content to be pushed (note that the following requires the dev site to be running with `make dev-run`):
```
make prepare
```
Stop the remote website
```
ssh ${REMOTE_WEB_HOST} docker stop wordpress_askar
```
Push the database
```
make push-db
```
Push the website content
```
make push-website
```
Restart the website
```
ssh ${REMOTE_WEB_HOST} ./ wordpress_askar.sh
```

6
assets/db.prod.pass.age Normal file
View File

@ -0,0 +1,6 @@
age-encryption.org/v1
-> scrypt 6QrVQqHCz74QP99Wdncdlg 18
6pKNpuQEpUOPQRo/EBndnQS6SiX5Vk5SarrCQyQV76I
--- 3HNXyrypprIaex+N5i6H9aqV/r38nYg2jYj+aG4xShA
öÞ³ú¥öh
$jYÿŸ¹ õ"Æù<C386>±MRÀ¯7‰áƵãùöKÈ<pŽÇ_Á¦Û