Compare commits

...

9 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
Jean-Christophe Vanhalle
07368aff02 adds default launch.json for laravel, livewire and php project 2024-10-22 20:07:47 +02:00
Jean-Christophe Vanhalle
e61b00b184 updates www user shell prompt with colours 2024-10-22 20:03:28 +02:00
Jean-Christophe Vanhalle
22a6286487 adds php project type 2024-10-18 12:48:17 +02:00
Jean-Christophe Vanhalle
a51f2ae8f3 renames wp.sh to www.sh 2024-10-15 16:32:10 +02:00
8 changed files with 120 additions and 5 deletions

View File

@@ -3,3 +3,11 @@
- [ ] 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)
- [ ] 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"
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}"
mkdir -p "${backup_path}"
volumes="db root traefik-dynamic traefik-certs traefik-logs traefik-static webroot"
volumes="db"
for volume in ${volumes}; do
mkdir -p "${backup_path}/${volume}"
docker run \
@@ -25,9 +28,24 @@ for volume in ${volumes}; do
tar -cvzf "/destination/${volume}.tar.gz" -C "/${volume}" .
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"
docker exec "${PREFIX}-db" \
/usr/bin/mysqldump \
-u root \
--password="${DB_ROOT_PASSWORD}" \
"${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

@@ -137,7 +137,48 @@ if [ "${PROJECT_TYPE}" = "wintercms" ]; then
docker exec --user www-data --workdir "/var/www/html" -it "${PREFIX}-app" /bin/sh -c "php artisan winter:install"
fi
if [ "${PROJECT_TYPE}" = "laravel" ] || [ "${PROJECT_TYPE}" = "livewire" ] || [ "${PROJECT_TYPE}" = "php" ]; then
echo "Generating vscode launch.json file"
cat << EOF > /tmp/${PREFIX}/launch.json
{
"version": "0.2.0",
"configurations": [
{
"hostname": "${TRAEFIK_LISTENING_IP}",
"name": "Listen for Xdebug (${TRAEFIK_LISTENING_IP})",
"pathMappings": {
"/var/www/html/": "\${workspaceRoot}/",
},
"port": 9003,
"request": "launch",
"type": "php"
}
]
}
EOF
docker run \
--rm \
--user www-data \
--volume "${PREFIX}-app":/destination \
ubuntu \
mkdir --parents /destination/.vscode
docker run \
--rm \
--user www-data \
--volume "${PREFIX}-app":/destination \
ubuntu \
cp /source/launch.json /destination/.vscode
docker run \
--rm \
--user root \
--volume "${PREFIX}-app":/destination \
ubuntu \
chown www-data:www-data /destination/.vscode -r
fi
if [ "${PROJECT_TYPE}" = "wordpress" ]; then
echo "Installing wppb-cli"
composer global require tmeister/wppb-cli
echo "Downloading WordPress core"
docker exec --user www-data "${PREFIX}-app" /bin/sh -c "
wp core download \

View File

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

View File

@@ -1,4 +1,5 @@
PROJECT_TYPE=wordpress
PROJECT_TYPE=laravel
PROJECT_TYPE=livewire
PROJECT_TYPE=php
PROJECT_TYPE=wintercms
PROJECT_TYPE=wordpress

View File

@@ -6,8 +6,8 @@ set -a
set +a
docker exec \
-e SHELLOPTS=vi \
-e HISTFILE=/var/www/html/.bash_history \
-e SHELLOPTS=vi \
-it --user www-data \
"${PREFIX}-app" \
/bin/bash