Compare commits

..

5 Commits

Author SHA1 Message Date
Jean-Christophe Vanhalle
062c764c9b adds generic check-diff utility script 2025-06-27 23:45:18 +02:00
Jean-Christophe Vanhalle
c5716b8f7a fixes bug where no sql dump was created 2025-06-27 23:01:07 +02:00
Jean-Christophe Vanhalle
7331fcf2d0 removes version parameter, adds external: true for volumes 2025-05-12 10:04:25 +02:00
Jean-Christophe Vanhalle
8997df6327 adds wppb-cli 2024-11-02 13:51:10 +01:00
Jean-Christophe Vanhalle
fbcba7cde4 removes shell parameters since it's handled in /etc/bash.bashrc 2024-10-23 09:47:12 +02:00
7 changed files with 79 additions and 4 deletions

View File

@@ -3,3 +3,11 @@
- [ ] ajouter un moyen d'accéder à la db via un port - [ ] ajouter un moyen d'accéder à la db via un port
- [ ] ajouter une option pour créer sans traefik et sans adminer (via override compose) - [ ] ajouter une option pour créer sans traefik et sans adminer (via override compose)
- [ ] remplacer -a par --recursive,etc pour éviter qu'rsync n'affiche un transfert si atime, ctime, mtime a changé pour un fichier - [ ] remplacer -a par --recursive,etc pour éviter qu'rsync n'affiche un transfert si atime, ctime, mtime a changé pour un fichier
# wintercms
- [ ] configurer l'écran de login du back-end en HTTPS
# wordpress
- [ ] documenter wppb-cli

View File

@@ -10,11 +10,14 @@ set -a
. "${PWD}/.env" . "${PWD}/.env"
set +a set +a
now="$(date +%Y-%m_%d-%H-%M-%S)" docker compose stop
now="$(date +%Y-%m-%d_%H-%M-%S)"
backup_path="${PWD}/backup-volumes/${now}" backup_path="${PWD}/backup-volumes/${now}"
mkdir -p "${backup_path}" mkdir -p "${backup_path}"
volumes="db root traefik-dynamic traefik-certs traefik-logs traefik-static webroot" volumes="db root traefik-dynamic traefik-certs traefik-logs traefik-static webroot"
volumes="db"
for volume in ${volumes}; do for volume in ${volumes}; do
mkdir -p "${backup_path}/${volume}" mkdir -p "${backup_path}/${volume}"
docker run \ docker run \
@@ -25,9 +28,24 @@ for volume in ${volumes}; do
tar -cvzf "/destination/${volume}.tar.gz" -C "/${volume}" . tar -cvzf "/destination/${volume}.tar.gz" -C "/${volume}" .
done done
docker compose restart db
docker compose restart app
while ! docker ps -q -f name="${PREFIX}-db"; do
echo "Waiting for the db container to be up and running..."
sleep 1
done
while ! docker exec "${PREFIX}-app" /bin/sh -c "mysqladmin ping -h ${PREFIX}-db -P 3306 --protocol=tcp -u user -puser --silent"; do
echo "Waiting for the mysql server in the db container to be up and running and reachable from the app container..."
sleep 1
done
mkdir -p "${backup_path}/db" mkdir -p "${backup_path}/db"
docker exec "${PREFIX}-db" \ docker exec "${PREFIX}-db" \
/usr/bin/mysqldump \ /usr/bin/mysqldump \
-u root \ -u root \
--password="${DB_ROOT_PASSWORD}" \ --password="${DB_ROOT_PASSWORD}" \
"${DB_NAME}" > "${backup_path}/db/${DB_NAME}.sql" "${DB_NAME}" > "${backup_path}/db/${DB_NAME}.sql"
docker compose stop db
docker compose stop app

35
check-diff.sh Normal file
View File

@@ -0,0 +1,35 @@
#! /bin/sh
#
set -x
if [ "$#" -eq 0 ] || [ "$#" -gt 1 ]; then
echo takes only one argument
exit 1
fi
if [ ! -e "${1}" ]; then
echo cannot find "${1}"
exit 1
fi
# shellcheck source=./env_files/checkdiff-example.env
. "${1}"
remote_copy_path=$(mktemp -d)
rsync \
--archive \
--checksum \
--human-readable \
"${REMOTE_SSH_STRING}":"${REMOTE_ROOT_PATH}${FOLDER_PATH}/" \
"${remote_copy_path}"
local_copy_path=$(mktemp -d)
rsync \
--archive \
--checksum \
--exclude-from="${EXCLUDEFILE_PATH}" \
--human-readable \
"${LOCAL_ROOT_PATH}${FOLDER_PATH}/" \
"${local_copy_path}"
kdiff3 "${local_copy_path}" "${remote_copy_path}"

View File

@@ -177,6 +177,8 @@ EOF
fi fi
if [ "${PROJECT_TYPE}" = "wordpress" ]; then if [ "${PROJECT_TYPE}" = "wordpress" ]; then
echo "Installing wppb-cli"
composer global require tmeister/wppb-cli
echo "Downloading WordPress core" echo "Downloading WordPress core"
docker exec --user www-data "${PREFIX}-app" /bin/sh -c " docker exec --user www-data "${PREFIX}-app" /bin/sh -c "
wp core download \ wp core download \

View File

@@ -78,24 +78,31 @@ services:
- traefik-logs:/logs - traefik-logs:/logs
- traefik-static:/etc/traefik/static:ro - traefik-static:/etc/traefik/static:ro
version: "3.4"
volumes: volumes:
cache: cache:
external: true
name: composer-cache name: composer-cache
db: db:
external: true
name: ${PREFIX}-db name: ${PREFIX}-db
root: root:
external: true
name: ${PREFIX}-root name: ${PREFIX}-root
traefik-certs: traefik-certs:
external: true
name: ${PREFIX}-traefik-certs name: ${PREFIX}-traefik-certs
traefik-dynamic: traefik-dynamic:
external: true
name: ${PREFIX}-traefik-dynamic name: ${PREFIX}-traefik-dynamic
traefik-logs: traefik-logs:
external: true
name: ${PREFIX}-traefik-logs name: ${PREFIX}-traefik-logs
traefik-static: traefik-static:
external: true
name: ${PREFIX}-traefik-static name: ${PREFIX}-traefik-static
webroot: webroot:
external: true
name: ${PREFIX}-webroot name: ${PREFIX}-webroot
wp-cli-cache: wp-cli-cache:
external: true
name: wp-cli-cache name: wp-cli-cache

View File

@@ -0,0 +1,5 @@
REMOTE_SSH_STRING=<sshconfig hostname>
REMOTE_ROOT_PATH=</var/www/example.com/www>
LOCAL_ROOT_PATH=</home/user/dev/www>
FOLDER_PATH=</wp-content/themes/bar>
EXCLUDEFILE_PATH=<./deployment/example.com.bar.exclude>

2
www.sh
View File

@@ -10,4 +10,4 @@ docker exec \
-e SHELLOPTS=vi \ -e SHELLOPTS=vi \
-it --user www-data \ -it --user www-data \
"${PREFIX}-app" \ "${PREFIX}-app" \
/bin/bash -c '\nwww-data@${HOSTNAME} \[\033[01;35m\]\w\[\033[00m\]\n$ ' /bin/bash