Compare commits
51 Commits
222d86a909
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
062c764c9b | ||
|
|
c5716b8f7a | ||
|
|
7331fcf2d0 | ||
|
|
8997df6327 | ||
|
|
fbcba7cde4 | ||
|
|
07368aff02 | ||
|
|
e61b00b184 | ||
|
|
22a6286487 | ||
|
|
a51f2ae8f3 | ||
|
|
441dc6b371 | ||
|
|
cde2a715fb | ||
|
|
c55c46df0d | ||
|
|
4971511309 | ||
|
|
95391a995c | ||
|
|
6e0719ec50 | ||
|
|
c1ae487788 | ||
|
|
d582d4c7f0 | ||
|
|
f94e7baba5 | ||
|
|
3c22799e47 | ||
|
|
ba2b4bdaa1 | ||
|
|
bbd07933ff | ||
|
|
f86fa8b9f3 | ||
|
|
d0a70be1b2 | ||
|
|
f3afb76350 | ||
|
|
f85c57c9b9 | ||
|
|
4e845592e2 | ||
|
|
12d556d660 | ||
|
|
deb52616bf | ||
|
|
75298677b0 | ||
|
|
d71b16e10f | ||
|
|
623bd1741d | ||
|
|
7c72290ccf | ||
|
|
a48fa2525f | ||
|
|
bc14e41615 | ||
|
|
77730f0873 | ||
|
|
734e6f2824 | ||
|
|
27cb4ba4ec | ||
|
|
110f8aee3c | ||
|
|
5e1f6753f9 | ||
|
|
aec637df6f | ||
|
|
ea9c15f23a | ||
|
|
e807e5ee19 | ||
|
|
297df423c7 | ||
|
|
5d53a19803 | ||
|
|
a46ef7de81 | ||
|
|
d27b5fb591 | ||
|
|
1388e97ae2 | ||
|
|
ae3ed5d2eb | ||
|
|
5bbb4bd2ca | ||
|
|
7dcaa8b1d5 | ||
|
|
b47876ad62 |
22
.env-example
22
.env-example
@@ -1,14 +1,20 @@
|
||||
APP_IMAGE_TAG=mywp:8.2.8-apache
|
||||
APP_URL=wpdocker.test
|
||||
DB_NAME=wordpress
|
||||
DB_ROOT_PASSWORD=root
|
||||
DB_USER=user
|
||||
DB_USER_PASSWORD=user
|
||||
DOCKER_PREFIX=wp
|
||||
DOCKER_IMAGE_TAG=wp-php7.4:dev
|
||||
MOUNT_USER=username
|
||||
TRAEFIK_NETWORK_NAME=traefik
|
||||
DB_USER_PASSWORD=password
|
||||
LARAVEL_VERSION=11.0
|
||||
LIVEWIRE_VERSION=3.5.10
|
||||
PHP_POST_MAX_SIZE=10m
|
||||
PHP_UPLOAD_MAX_FILESIZE=10M
|
||||
PREFIX=wpdocker
|
||||
TRAEFIK_LISTENING_IP=192.168.2.108
|
||||
WP_ADMIN_PASSWORD=admin
|
||||
WP_ADMIN_USERNAME=admin
|
||||
WP_DEFAULT_PROTOCOL=https
|
||||
WP_LOCALE=fr_FR
|
||||
WP_THEME=twentyseventeen
|
||||
WP_URL=www.wp.localhost
|
||||
WP_VERSION=5.7
|
||||
WP_THEME=twentytwentytwo
|
||||
WP_VERSION=6.3
|
||||
XDEBUG_CLIENT_HOST=192.168.2.108
|
||||
XDEBUG_MODE=debug
|
||||
|
||||
12
.gitignore
vendored
Normal file
12
.gitignore
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
.env
|
||||
backup-volumes/
|
||||
exclude-list
|
||||
root-volume/
|
||||
tmp/
|
||||
traefik-volumes/
|
||||
webroot-remote/
|
||||
webroot-volume/
|
||||
/env_files/*
|
||||
!/env_files/*example*
|
||||
/deployment/*
|
||||
!/deployment/*example*
|
||||
13
TODO.md
Normal file
13
TODO.md
Normal file
@@ -0,0 +1,13 @@
|
||||
- [ ] modifier pull-remote-db.sh pour qu'il fasse tourner wp-cli directement sur le conteneur et récupère ensuite le contenu localement
|
||||
- [ ] ajouter dump sql au backup
|
||||
- [ ] 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
|
||||
51
backup.sh
Executable file
51
backup.sh
Executable file
@@ -0,0 +1,51 @@
|
||||
#! /bin/sh
|
||||
#
|
||||
|
||||
if [ ! -f "${PWD}/.env" ]; then
|
||||
echo "missing env file in ${PWD}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
set -a
|
||||
. "${PWD}/.env"
|
||||
set +a
|
||||
|
||||
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 \
|
||||
--rm \
|
||||
--volume "${backup_path}/${volume}":/destination \
|
||||
--volume "${PREFIX}-${volume}:/${volume}" \
|
||||
ubuntu \
|
||||
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
35
check-diff.sh
Normal 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}"
|
||||
226
create.sh
226
create.sh
@@ -1,63 +1,196 @@
|
||||
#! /bin/sh
|
||||
#
|
||||
|
||||
if [ -f .env ]
|
||||
then
|
||||
set -o allexport;
|
||||
. ./.env;
|
||||
set +o allexport
|
||||
else
|
||||
echo Missing .env file
|
||||
if [ ! -f "${PWD}/.env" ]; then
|
||||
echo "missing env file in ${PWD}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo Setting up ${DOCKER_PREFIX} volumes
|
||||
docker volume create ${DOCKER_PREFIX}-web
|
||||
docker volume create ${DOCKER_PREFIX}-db
|
||||
set -a
|
||||
. "${PWD}/.env"
|
||||
. "${PWD}/env_files/certs.env"
|
||||
. "${PWD}/env_files/project.env"
|
||||
set +a
|
||||
|
||||
mkdir -p "/tmp/${PREFIX}"
|
||||
|
||||
echo "Setting up docker volumes"
|
||||
docker volume create "${PREFIX}-db"
|
||||
docker volume create "${PREFIX}-root"
|
||||
docker volume create "${PREFIX}-traefik-certs"
|
||||
docker volume create "${PREFIX}-traefik-dynamic"
|
||||
docker volume create "${PREFIX}-traefik-logs"
|
||||
docker volume create "${PREFIX}-traefik-static"
|
||||
docker volume create "${PREFIX}-webroot"
|
||||
docker volume create wp-cli-cache
|
||||
echo Setting up ${DOCKER_PREFIX} network
|
||||
docker network create ${DOCKER_PREFIX}
|
||||
docker volume create composer-cache
|
||||
|
||||
docker-compose up -d web
|
||||
while [ ! $(docker ps --quiet --filter name=${DOCKER_PREFIX}-web) ]
|
||||
do
|
||||
echo Waiting for the ${DOCKER_PREFIX}-web container to be up and running…
|
||||
echo "Copying SSL certificates to traefik volume"
|
||||
if [ ! -f "${SSL_CRT_LOCATION}/${SSL_CRT_NAME}" ] || [ ! -f "${SSL_KEY_LOCATION}/${SSL_KEY_NAME}" ]; then
|
||||
echo "Missing SSL key or cert file"
|
||||
exit 1
|
||||
fi
|
||||
docker run \
|
||||
--rm \
|
||||
--volume "${PREFIX}-traefik-certs":/certs \
|
||||
--volume "${SSL_CRT_LOCATION}":/source \
|
||||
ubuntu \
|
||||
cp "/source/${SSL_CRT_NAME}" /certs
|
||||
docker run \
|
||||
--rm \
|
||||
--volume "${PREFIX}-traefik-certs":/certs \
|
||||
--volume "${SSL_KEY_LOCATION}":/source \
|
||||
ubuntu \
|
||||
cp "/source/${SSL_KEY_NAME}" /certs
|
||||
|
||||
echo "Generating traefik configuration files (ssl.yml and middlewares.yml)"
|
||||
cat << EOF > /tmp/${PREFIX}/ssl.yml
|
||||
---
|
||||
tls:
|
||||
stores:
|
||||
default:
|
||||
defaultCertificate:
|
||||
certFile: /certs/${SSL_CRT_NAME}
|
||||
keyFile: /certs/${SSL_KEY_NAME}
|
||||
EOF
|
||||
cat << EOF > /tmp/${PREFIX}/middlewares.yml
|
||||
---
|
||||
http:
|
||||
middlewares:
|
||||
https-redirect:
|
||||
redirectscheme:
|
||||
scheme: https
|
||||
permanent: true
|
||||
EOF
|
||||
docker run \
|
||||
--rm \
|
||||
--volume "/tmp/${PREFIX}":/source \
|
||||
--volume "${PREFIX}-traefik-dynamic":/destination \
|
||||
ubuntu \
|
||||
cp /source/ssl.yml /source/middlewares.yml /destination
|
||||
|
||||
echo "Generating traefik static configuration"
|
||||
cat << EOF > /tmp/${PREFIX}/static.yml
|
||||
---
|
||||
api:
|
||||
dashboard: true
|
||||
entrypoints:
|
||||
http:
|
||||
address: :80
|
||||
https:
|
||||
address: :443
|
||||
log:
|
||||
filepath: /logs/traefik.log
|
||||
level: debug
|
||||
providers:
|
||||
docker:
|
||||
exposedbydefault: false
|
||||
file:
|
||||
directory: /etc/traefik/dynamic
|
||||
watch: true
|
||||
EOF
|
||||
docker run \
|
||||
--rm \
|
||||
--volume "/tmp/${PREFIX}":/source \
|
||||
--volume "${PREFIX}-traefik-static":/destination \
|
||||
ubuntu \
|
||||
cp /source/static.yml /destination/traefik.yml
|
||||
|
||||
docker compose up -d app
|
||||
while ! docker ps -q -f name="${PREFIX}-app"; do
|
||||
echo "Waiting for the web container to be up and running..."
|
||||
sleep 1
|
||||
done
|
||||
|
||||
docker-compose up -d db
|
||||
while [ ! $(docker ps -q -f name=${DOCKER_PREFIX}-db) ]
|
||||
do
|
||||
echo Waiting for the ${DOCKER_PREFIX}-db container to be up and running…
|
||||
docker compose up -d db
|
||||
while ! docker ps -q -f name="${PREFIX}-db"; do
|
||||
echo "Waiting for the db container to be up and running..."
|
||||
sleep 1
|
||||
done
|
||||
|
||||
PING_MYSQL="mysqladmin \
|
||||
ping \
|
||||
--host ${DOCKER_PREFIX}-db \
|
||||
--port 3306 \
|
||||
--protocol=tcp \
|
||||
--user=${DB_USER} \
|
||||
--password=${DB_USER_PASSWORD} \
|
||||
--silent"
|
||||
while ! docker exec ${DOCKER_PREFIX}-web /bin/sh -c "${PING_MYSQL}"
|
||||
do
|
||||
echo Waiting for ${DOCKER_PREFIX}-db to accept connections…
|
||||
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
|
||||
|
||||
echo Downloading WordPress core
|
||||
docker exec --user www-data ${DOCKER_PREFIX}-web /bin/sh -c "
|
||||
if [ "${PROJECT_TYPE}" = "laravel" ]; then
|
||||
echo "Installing laravel"
|
||||
docker exec --user www-data --workdir "/var/www/html" "${PREFIX}-app" /bin/sh -c "composer create-project --prefer-dist laravel/laravel /var/www/html '${LAREVEL_VERSION}'"
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_TYPE}" = "livewire" ]; then
|
||||
echo "Installing livewire"
|
||||
docker exec --user www-data --workdir "/var/www/html" "${PREFIX}-app" /bin/sh -c "composer create-project --prefer-dist laravel/laravel /var/www/html '${LARAVEL_VERSION}'"
|
||||
docker exec --user www-data --workdir "/var/www/html" "${PREFIX}-app" /bin/sh -c "composer require livewire/livewire ${LIVEWIRE_VERSION}"
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_TYPE}" = "wintercms" ]; then
|
||||
echo "Installing wintercms"
|
||||
docker exec --user www-data --workdir "/var/www/html" "${PREFIX}-app" /bin/sh -c "composer create-project wintercms/winter /var/www/html"
|
||||
docker exec --user www-data --workdir "/var/www/html" "${PREFIX}-app" /bin/sh -c "echo ASSET_URL=https://${APP_URL} >> /var/www/html/.env"
|
||||
docker exec --user www-data --workdir "/var/www/html" "${PREFIX}-app" /bin/sh -c "echo DB_DATABASE=${DB_NAME} >> /var/www/html/.env"
|
||||
docker exec --user www-data --workdir "/var/www/html" "${PREFIX}-app" /bin/sh -c "echo DB_USERNAME=${DB_USER} >> /var/www/html/.env"
|
||||
docker exec --user www-data --workdir "/var/www/html" "${PREFIX}-app" /bin/sh -c "echo DB_PASSWORD=${DB_USER_PASSWORD} >> /var/www/html/.env"
|
||||
docker exec --user www-data --workdir "/var/www/html" "${PREFIX}-app" /bin/sh -c "echo DB_HOST=${PREFIX}-db >> /var/www/html/.env"
|
||||
docker exec --user root "${PREFIX}-app" /bin/sh -c "sed -i 's|/var/www/html/public|/var/www/html|g' /etc/apache2/sites-available/000-default.conf"
|
||||
docker restart "${PREFIX}-app"
|
||||
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 \
|
||||
--locale=${WP_LOCALE} \
|
||||
--path=/var/www/html \
|
||||
--version=${WP_VERSION}"
|
||||
|
||||
echo Creating ${DOCKER_PREFIX} WordPress config
|
||||
docker exec --user www-data ${DOCKER_PREFIX}-web /bin/sh -c '
|
||||
echo "Creating WordPress config"
|
||||
docker exec --user www-data "${PREFIX}-app" /bin/sh -c '
|
||||
wp config create \
|
||||
--dbhost='"${DOCKER_PREFIX}-db"' \
|
||||
--dbname='"${DOCKER_PREFIX}"' \
|
||||
--dbhost='"${PREFIX}-db"' \
|
||||
--dbname='"${DB_NAME}"' \
|
||||
--dbpass='"${DB_USER_PASSWORD}"' \
|
||||
--dbuser='"${DB_USER}"' \
|
||||
--force \
|
||||
@@ -68,23 +201,24 @@ if (isset(\$_SERVER["HTTP_X_FORWARDED_PROTO"]) && \$_SERVER["HTTP_X_FORWARDED_PR
|
||||
EXTRA-PHP
|
||||
'
|
||||
|
||||
echo Installing WordPress core
|
||||
docker exec --user www-data ${DOCKER_PREFIX}-web /bin/sh -c "
|
||||
echo "Installing WordPress core"
|
||||
docker exec --user www-data "${PREFIX}-app" /bin/sh -c "
|
||||
wp core install \
|
||||
--admin_email=no@mail.com \
|
||||
--admin_password=${WP_ADMIN_PASSWORD} \
|
||||
--admin_user=${WP_ADMIN_USERNAME} \
|
||||
--path=/var/www/html \
|
||||
--skip-email \
|
||||
--title=${DOCKER_PREFIX} \
|
||||
--url=${WP_DEFAULT_PROTOCOL}://${WP_URL}"
|
||||
--title=${PREFIX} \
|
||||
--url=${WP_DEFAULT_PROTOCOL}://${APP_URL}"
|
||||
|
||||
echo Installing WordPress ${WP_THEME} theme
|
||||
docker exec --user www-data ${DOCKER_PREFIX}-web /bin/sh -c "
|
||||
echo "Installing WordPress "${WP_THEME}" theme"
|
||||
docker exec --user www-data "${PREFIX}-app" /bin/sh -c "
|
||||
wp theme install ${WP_THEME} \
|
||||
--activate \
|
||||
--path=/var/www/html"
|
||||
fi
|
||||
|
||||
echo Connect ${DOCKER_PREFIX} network to ${TRAEFIK_NETWORK_NAME}
|
||||
docker network connect ${DOCKER_PREFIX} ${TRAEFIK_NETWORK_NAME}
|
||||
docker-compose up -d adminer
|
||||
docker compose up -d adminer
|
||||
docker compose up -d app
|
||||
docker compose up -d traefik
|
||||
|
||||
63
deploy-directory-to-remote.sh
Executable file
63
deploy-directory-to-remote.sh
Executable file
@@ -0,0 +1,63 @@
|
||||
#! /bin/sh
|
||||
#
|
||||
|
||||
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=./deployment/deployment-example.env
|
||||
. "${1}"
|
||||
|
||||
if [ "${do_backup}" = "yes" ]; then
|
||||
if ssh ${remote_ssh_string} "mkdir --parents ${remote_deployment_directory_path}"; then
|
||||
echo deployment folder successfully created on remote
|
||||
else
|
||||
echo deployment folder creation on remote failed
|
||||
exit 1
|
||||
fi
|
||||
if ssh ${remote_ssh_string} "cp --archive --recursive ${remote_directory_path} ${remote_deployment_directory_path}/$(basename ${remote_directory_path}).backup.${now}"; then
|
||||
echo backup of current remote directory successfully created on remote
|
||||
else
|
||||
echo backup of current remote directory failed
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "${use_maintenance_mode}" = "yes" ]; then
|
||||
if ssh ${remote_ssh_string} "wp option patch update wpmm_settings general status 1 --path=${remote_wp_path}"; then
|
||||
echo maintenance mode activated
|
||||
else
|
||||
echo something went horribly wrong
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# --update removed after kartolok-child shenaningans
|
||||
# --checksum added instead
|
||||
if rsync --checksum --compress --delete --delete-excluded --exclude-from="${deployment_exclude_file}" --executability --human-readable --progress --recursive "${local_directory_path}/" "${remote_ssh_string}":"${remote_directory_path}"; then
|
||||
echo syncing OK
|
||||
else
|
||||
echo syncing NOK
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "${use_maintenance_mode}" = "yes" ]; then
|
||||
if ssh ${remote_ssh_string} "wp option patch update wpmm_settings general status 0 --path=${remote_wp_path}"; then
|
||||
echo maintenance mode deactivated
|
||||
else
|
||||
echo something went horribly wrong
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "${restart_remote_varnish}" = "yes" ]; then
|
||||
set -x
|
||||
ssh "${sudo_remote_ssh_string}" sudo service varnish restart
|
||||
set +x
|
||||
fi
|
||||
12
deployment/deployment-example.env
Normal file
12
deployment/deployment-example.env
Normal file
@@ -0,0 +1,12 @@
|
||||
deployment_exclude_file=
|
||||
local_directory_path=
|
||||
now="$(date +%Y-%m-%d-%H-%M-%S)"
|
||||
remote_deployment_directory_path=
|
||||
remote_directory_path=
|
||||
remote_ssh_string=
|
||||
remote_wp_path=
|
||||
remote_is_docker=
|
||||
restart_remote_varnish=no
|
||||
sudo_remote_ssh_string=
|
||||
use_maintenance_mode=no
|
||||
do_backup=yes
|
||||
@@ -1,51 +1,108 @@
|
||||
---
|
||||
networks:
|
||||
default:
|
||||
external:
|
||||
name: ${DOCKER_PREFIX}
|
||||
name: ${PREFIX}
|
||||
|
||||
services:
|
||||
adminer:
|
||||
container_name: ${DOCKER_PREFIX}-adminer
|
||||
hostname: ${DOCKER_PREFIX}-adminer
|
||||
image: adminer:4.7.2-standalone
|
||||
container_name: ${PREFIX}-adminer
|
||||
dns:
|
||||
- 1.1.1.1
|
||||
hostname: ${PREFIX}-adminer
|
||||
image: adminer:4.8.1-standalone
|
||||
labels:
|
||||
- traefik.enable=true
|
||||
- traefik.http.routers.${DOCKER_PREFIX}-adminer.entrypoints=https
|
||||
- traefik.http.routers.${DOCKER_PREFIX}-adminer.rule=Host(`${WP_URL}`) && PathPrefix(`/adminer/`)
|
||||
- traefik.http.routers.${DOCKER_PREFIX}-adminer.tls=true # remove if using LE as default TLS
|
||||
- traefik.http.services.${DOCKER_PREFIX}-adminer.loadbalancer.server.port=8080
|
||||
- traefik.http.routers.${PREFIX}-adminer.entrypoints=https
|
||||
- traefik.http.routers.${PREFIX}-adminer.rule=Host(`adminer.${APP_URL}`)
|
||||
- traefik.http.routers.${PREFIX}-adminer.tls=true
|
||||
- traefik.http.services.${PREFIX}-adminer.loadbalancer.server.port=8080
|
||||
app:
|
||||
container_name: ${PREFIX}-app
|
||||
dns:
|
||||
- 1.1.1.1
|
||||
environment:
|
||||
- PHP_POST_MAX_SIZE=${PHP_POST_MAX_SIZE}
|
||||
- PHP_UPLOAD_MAX_FILESIZE=${PHP_UPLOAD_MAX_FILESIZE}
|
||||
- XDEBUG_CLIENT_HOST=${XDEBUG_CLIENT_HOST}
|
||||
- XDEBUG_MODE=${XDEBUG_MODE}
|
||||
hostname: ${PREFIX}-app
|
||||
image: ${APP_IMAGE_TAG}
|
||||
labels:
|
||||
- traefik.enable=true
|
||||
- traefik.http.routers.${PREFIX}-web.entrypoints=http
|
||||
- traefik.http.routers.${PREFIX}-web.middlewares=https-redirect@file
|
||||
- traefik.http.routers.${PREFIX}-web.rule=Host(`${APP_URL}`)
|
||||
- traefik.http.routers.${PREFIX}-webssl.entrypoints=https
|
||||
- traefik.http.routers.${PREFIX}-webssl.rule=Host(`${APP_URL}`)
|
||||
- traefik.http.routers.${PREFIX}-webssl.tls=true
|
||||
- traefik.http.services.${PREFIX}-webssl.loadbalancer.server.port=80
|
||||
volumes:
|
||||
- root:/root
|
||||
- webroot:/var/www/html
|
||||
- wp-cli-cache:/var/www/.wp-cli
|
||||
- cache:/var/www/.cache
|
||||
db:
|
||||
command: --default-authentication-plugin=mysql_native_password
|
||||
container_name: ${DOCKER_PREFIX}-db
|
||||
container_name: ${PREFIX}-db
|
||||
environment:
|
||||
MYSQL_DATABASE: ${DOCKER_PREFIX}
|
||||
MYSQL_DATABASE: ${DB_NAME}
|
||||
MYSQL_PASSWORD: ${DB_USER_PASSWORD}
|
||||
MYSQL_ROOT_PASSWORD: ${DB_ROOT_PASSWORD}
|
||||
MYSQL_USER: ${DB_USER}
|
||||
hostname: ${DOCKER_PREFIX}-db
|
||||
hostname: ${PREFIX}-db
|
||||
image: mariadb:10.4.6-bionic
|
||||
ports:
|
||||
- "${TRAEFIK_LISTENING_IP}:3306:3306"
|
||||
volumes:
|
||||
- db:/var/lib/mysql
|
||||
web:
|
||||
container_name: ${DOCKER_PREFIX}-web
|
||||
image: ${DOCKER_IMAGE_TAG}
|
||||
traefik:
|
||||
container_name: ${PREFIX}-traefik
|
||||
command: ["--configFile=/etc/traefik/static/traefik.yml"]
|
||||
dns:
|
||||
- 1.1.1.1
|
||||
image: traefik:2.5.3
|
||||
labels:
|
||||
- traefik.enable=true
|
||||
- traefik.http.routers.${DOCKER_PREFIX}-web.entrypoints=https
|
||||
- traefik.http.routers.${DOCKER_PREFIX}-web.rule=Host(`${WP_URL}`)
|
||||
- traefik.http.routers.${DOCKER_PREFIX}-web.tls=true # remove if using LE as default TLS provider
|
||||
- traefik.http.services.${DOCKER_PREFIX}-web.loadbalancer.server.port=80
|
||||
- traefik.http.routers.${PREFIX}-traefik.entrypoints=https
|
||||
- traefik.http.routers.${PREFIX}-traefik.rule=Host(`traefik.${APP_URL}`)
|
||||
- traefik.http.routers.${PREFIX}-traefik.service=api@internal
|
||||
- traefik.http.routers.${PREFIX}-traefik.tls=true
|
||||
ports:
|
||||
- "${TRAEFIK_LISTENING_IP}:80:80"
|
||||
- "${TRAEFIK_LISTENING_IP}:443:443"
|
||||
volumes:
|
||||
- web:/var/www/html
|
||||
- wp-cli-cache:/var/www/.wp-cli
|
||||
|
||||
version: "3.4"
|
||||
- /etc/localtime:/etc/localtime:ro
|
||||
- /var/run/docker.sock:/var/run/docker.sock:ro
|
||||
- traefik-certs:/certs:ro
|
||||
- traefik-dynamic:/etc/traefik/dynamic:ro
|
||||
- traefik-logs:/logs
|
||||
- traefik-static:/etc/traefik/static:ro
|
||||
|
||||
volumes:
|
||||
cache:
|
||||
external: true
|
||||
name: composer-cache
|
||||
db:
|
||||
name: ${DOCKER_PREFIX}-db
|
||||
web:
|
||||
name: ${DOCKER_PREFIX}-web
|
||||
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
|
||||
|
||||
4
env_files/certs-example.env
Normal file
4
env_files/certs-example.env
Normal file
@@ -0,0 +1,4 @@
|
||||
SSL_CRT_LOCATION=<path>
|
||||
SSL_CRT_NAME=<certificate filename>
|
||||
SSL_KEY_LOCATION=<path>
|
||||
SSL_KEY_NAME=<key filename>
|
||||
5
env_files/checkdiff-example.env
Normal file
5
env_files/checkdiff-example.env
Normal 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
env_files/manage-example.env
Normal file
2
env_files/manage-example.env
Normal file
@@ -0,0 +1,2 @@
|
||||
MOUNT_USER=<local user>
|
||||
DOCKER_VOLUMES_PATH=</var/lib/docker/volumes>
|
||||
2
env_files/migrate-db-example.env
Normal file
2
env_files/migrate-db-example.env
Normal file
@@ -0,0 +1,2 @@
|
||||
REMOTE_WP_PATH=</var/www/example.com>
|
||||
REMOTE_WP_URL=<example.com>
|
||||
5
env_files/project-example.env
Normal file
5
env_files/project-example.env
Normal file
@@ -0,0 +1,5 @@
|
||||
PROJECT_TYPE=laravel
|
||||
PROJECT_TYPE=livewire
|
||||
PROJECT_TYPE=php
|
||||
PROJECT_TYPE=wintercms
|
||||
PROJECT_TYPE=wordpress
|
||||
2
env_files/remote-example.env
Normal file
2
env_files/remote-example.env
Normal file
@@ -0,0 +1,2 @@
|
||||
REMOTE_SSH_STRING=<sshconfig hostname>
|
||||
REMOTE_WP_PATH=</var/www/example.com>
|
||||
4
env_files/ssh-tunnel-example.env
Normal file
4
env_files/ssh-tunnel-example.env
Normal file
@@ -0,0 +1,4 @@
|
||||
LOCAL_IP_ON_REMOTE=localhost
|
||||
LOCAL_PORT=5432
|
||||
LOCAL_PORT_ON_REMOTE=5432
|
||||
REMOTE_HOST=federal-non-interactive
|
||||
27
migrate-db-paths.sh
Executable file
27
migrate-db-paths.sh
Executable file
@@ -0,0 +1,27 @@
|
||||
#! /bin/sh
|
||||
#
|
||||
|
||||
set -a
|
||||
. "${PWD}/.env"
|
||||
. "${PWD}/env_files/migrate-db.env"
|
||||
set +a
|
||||
|
||||
echo wp migratedb find-replace --find="//${REMOTE_WP_URL}","${REMOTE_WP_PATH}" --replace="//${APP_URL}",/var/www/html
|
||||
|
||||
read -p "Do we run the thing ? " REPLY
|
||||
if [ "$REPLY" != "${REPLY#[YyOo]}" ]; then
|
||||
echo "we carry on"
|
||||
else
|
||||
echo "we stop"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
date +%H-%M-%S
|
||||
docker exec --user www-data "${PREFIX}-app" /bin/sh -c '
|
||||
wp plugin install wp-migrate-db ; \
|
||||
wp plugin activate wp-migrate-db ; \
|
||||
wp migratedb find-replace \
|
||||
--find='"//${REMOTE_WP_URL}"','"${REMOTE_WP_PATH}"' \
|
||||
--replace='"//${APP_URL}"',/var/www/html
|
||||
'
|
||||
date +%H-%M-%S
|
||||
41
mnt.sh
41
mnt.sh
@@ -1,41 +0,0 @@
|
||||
#! /bin/sh
|
||||
#
|
||||
|
||||
if [ -f .env ]
|
||||
then
|
||||
set -o allexport;
|
||||
. ./.env;
|
||||
set +o allexport
|
||||
else
|
||||
echo Missing .env file
|
||||
exit 1
|
||||
fi
|
||||
|
||||
docker_volumes_path=/home/${MOUNT_USER}/.docker-data/volumes # volume_path=/var/lib/docker/volumes
|
||||
volume_src_path=${docker_volumes_path}/${DOCKER_PREFIX}-web/_data
|
||||
volume_dest_path=${PWD}/volume
|
||||
|
||||
if [ ! -d ./volume ]
|
||||
then
|
||||
sudo -u ${MOUNT_USER} mkdir volume
|
||||
fi
|
||||
|
||||
if [ -d ./volume ]
|
||||
then
|
||||
if [ ! "$(ls -A ./volume)" ]
|
||||
then
|
||||
/usr/bin/bindfs \
|
||||
--force-user=${MOUNT_USER} \
|
||||
--force-group=${MOUNT_USER} \
|
||||
--create-for-user=www-data \
|
||||
--create-for-group=www-data \
|
||||
${volume_src_path} \
|
||||
${volume_dest_path}
|
||||
else
|
||||
echo ./volume is not empty
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo ./volume does not exist
|
||||
exit 1
|
||||
fi
|
||||
20
mount-remote.sh
Executable file
20
mount-remote.sh
Executable file
@@ -0,0 +1,20 @@
|
||||
#! /bin/sh
|
||||
#
|
||||
|
||||
set -a
|
||||
. "${PWD}/.env"
|
||||
. "${PWD}/env_files/remote.env"
|
||||
set +a
|
||||
|
||||
mkdir -p "${PWD}/webroot-remote"
|
||||
|
||||
if [ ! "${REMOTE_SSH_STRING}" = "" ]; then
|
||||
sshfs \
|
||||
"${REMOTE_SSH_STRING}:${REMOTE_WP_PATH}" \
|
||||
"${PWD}/webroot-remote" \
|
||||
-o ro
|
||||
ls "${PWD}/webroot-remote"
|
||||
else
|
||||
echo "REMOTE_SSH_STRING is empty in ${PWD}/.env"
|
||||
exit 1
|
||||
fi
|
||||
47
mount-volumes.sh
Executable file
47
mount-volumes.sh
Executable file
@@ -0,0 +1,47 @@
|
||||
#! /bin/sh
|
||||
#
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo "must be ran as root"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
set -a
|
||||
. "${PWD}/.env"
|
||||
. "${PWD}/env_files/manage.env"
|
||||
set +a
|
||||
|
||||
volumes="certs dynamic logs root static webroot"
|
||||
for volume in ${volumes}; do
|
||||
mount_path="${PWD}/traefik-volumes/${volume}"
|
||||
volume_path="${DOCKER_VOLUMES_PATH}/${PREFIX}-traefik-${volume}/_data"
|
||||
if [ "${volume}" = "webroot" ]; then
|
||||
mount_path="${PWD}/${volume}-volume"
|
||||
volume_path="${DOCKER_VOLUMES_PATH}/${PREFIX}-${volume}/_data"
|
||||
fi
|
||||
if [ "${volume}" = "root" ]; then
|
||||
mount_path="${PWD}/${volume}-volume"
|
||||
volume_path="${DOCKER_VOLUMES_PATH}/${PREFIX}-${volume}/_data"
|
||||
fi
|
||||
sudo -u "${MOUNT_USER}" mkdir -p "${mount_path}"
|
||||
if mountpoint "${mount_path}" -q; then
|
||||
echo "exiting because something is mounted at ${mount_path}"
|
||||
exit 1
|
||||
fi
|
||||
# if [ -n "$(find "${mount_path}" -maxdepth 0 -type d -empty 2> /dev/null)" ]; then
|
||||
if [ "$(ls -A "${mount_path}")" ]; then
|
||||
echo "${mount_path} is not empty"
|
||||
exit 1
|
||||
fi
|
||||
echo "mounting ${mount_path}"
|
||||
sudo /usr/bin/bindfs \
|
||||
--create-for-group=www-data \
|
||||
--create-for-user=www-data \
|
||||
--force-group="${MOUNT_USER}" \
|
||||
--force-user="${MOUNT_USER}" \
|
||||
"${volume_path}" \
|
||||
"${mount_path}"
|
||||
done
|
||||
|
||||
#tree "${PWD}/traefik-volumes"
|
||||
#tree "${PWD}/webroot-volume" -L 1
|
||||
62
pull-remote-db.sh
Executable file
62
pull-remote-db.sh
Executable file
@@ -0,0 +1,62 @@
|
||||
#! /bin/sh
|
||||
#
|
||||
|
||||
echo "ne fonctionne pas encore comme je veux, à ré-écrire pour docker, ne fonctionne que si accès ssh à un machine (ne marche pas avec un conteneur), ne fonctionnera pas à partir d'un conteneur sans clé SSH, doit avoir wp installé localement, etc."
|
||||
echo "en attendant: faire un dump de la remote db and utiliser replace-db et migrate-db"
|
||||
exit 0
|
||||
set -a
|
||||
. "${PWD}/.env"
|
||||
. "${PWD}/env_files/migrate-db.env"
|
||||
. "${PWD}/env_files/remote.env"
|
||||
set +a
|
||||
|
||||
mkdir --parents "${PWD}/tmp"
|
||||
|
||||
FILENAME="${REMOTE_WP_URL}".$(date +%Y-%m-%d-%H-%M-%S).sql
|
||||
|
||||
echo "wp \
|
||||
migratedb \
|
||||
export "/tmp/${FILENAME}.gz" \
|
||||
--find="//${REMOTE_WP_URL},${REMOTE_WP_PATH}" \
|
||||
--gzip-file \
|
||||
--path="${REMOTE_WP_PATH}" \
|
||||
--replace="//${APP_URL},/var/www/html" \
|
||||
--skip-replace-guids \
|
||||
--ssh="${REMOTE_SSH_STRING}""
|
||||
|
||||
wp \
|
||||
migratedb \
|
||||
export "/tmp/${FILENAME}.gz" \
|
||||
--find="//${REMOTE_WP_URL},${REMOTE_WP_PATH}" \
|
||||
--gzip-file \
|
||||
--path="${REMOTE_WP_PATH}" \
|
||||
--replace="//${APP_URL},/var/www/html" \
|
||||
--skip-replace-guids \
|
||||
--ssh="${REMOTE_SSH_STRING}"
|
||||
exit 0
|
||||
if ! scp "${REMOTE_SSH_STRING}:/tmp/${FILENAME}_.gz" "${PWD}/tmp"; then
|
||||
echo "couldn't get remote db"
|
||||
exit 1
|
||||
fi
|
||||
gunzip "${PWD}/tmp/${FILENAME}_.gz"
|
||||
exit 0
|
||||
docker compose up db -d
|
||||
|
||||
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}-db" /bin/sh -c "mysqladmin ping -h 127.0.0.1 -P 3306 --protocol=tcp -u root -p${DB_ROOT_PASSWORD} --silent"; do
|
||||
echo "Waiting for the mysql server in ${PREFIX}-db to be up and running..."
|
||||
sleep 1
|
||||
done
|
||||
|
||||
docker cp "${PWD}/tmp/${FILENAME}" "${PREFIX}"-db:/tmp
|
||||
|
||||
echo "dropping ${DB_NAME}"
|
||||
docker exec "${PREFIX}-db" /bin/sh -c "mysqladmin --force -uroot -p${DB_ROOT_PASSWORD} drop ${DB_NAME}"
|
||||
echo "creating ${DB_NAME}"
|
||||
docker exec "${PREFIX}-db" /bin/sh -c "mysqladmin -uroot -p${DB_ROOT_PASSWORD} create ${DB_NAME}"
|
||||
echo "importing ${PWD}/tmp/${FILENAME} (/tmp/${FILENAME}) into ${DB_NAME}"
|
||||
docker exec "${PREFIX}-db" /bin/sh -c "mysql -uroot -p${DB_ROOT_PASSWORD} ${DB_NAME} < /tmp/${FILENAME}"
|
||||
38
pull-remote-webroot.sh
Executable file
38
pull-remote-webroot.sh
Executable file
@@ -0,0 +1,38 @@
|
||||
#! /bin/sh
|
||||
#
|
||||
|
||||
read -p "Est-ce que le repertoire distant est bien monté localement (YyOo) ? " REPLY
|
||||
if [ "$REPLY" != "${REPLY#[YyOo]}" ]; then
|
||||
echo "we carry on"
|
||||
else
|
||||
echo "we stop"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
read -p "Est-ce que le volume docker est bien monté localement (YyOo) ? " REPLY2
|
||||
if [ "$REPLY2" != "${REPLY2#[YyOo]}" ]; then
|
||||
echo "we carry on"
|
||||
else
|
||||
echo "we stop"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cat ./exclude-list
|
||||
read -p "Est-ce que la commande rsync exclut bien un éventuel plugin ou thème en cours de développement en local (YyOo) ? " REPLY3
|
||||
if [ "$REPLY3" != "${REPLY3#[YyOo]}" ]; then
|
||||
echo "we carry on"
|
||||
else
|
||||
echo "we stop"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
rsync \
|
||||
--archive \
|
||||
--delete \
|
||||
--exclude '/wp-config.php' \
|
||||
--exclude-from='exclude-list' \
|
||||
--human-readable \
|
||||
--progress \
|
||||
--verbose \
|
||||
"${PWD}/webroot-remote/" \
|
||||
"${PWD}/webroot-volume"
|
||||
21
purge-local.sh
Executable file
21
purge-local.sh
Executable file
@@ -0,0 +1,21 @@
|
||||
#! /bin/sh
|
||||
#
|
||||
|
||||
set -a
|
||||
. "${PWD}/.env"
|
||||
set +a
|
||||
|
||||
read -p "Attention, ça va effacer les éventuels middlewares. Continuer (YyOo) ? " REPLY
|
||||
|
||||
if [ "$REPLY" != "${REPLY#[YyOo]}" ]; then
|
||||
docker compose stop
|
||||
docker compose rm
|
||||
docker network rm "${PREFIX}"
|
||||
docker volume rm "${PREFIX}-db"
|
||||
docker volume rm "${PREFIX}-root"
|
||||
docker volume rm "${PREFIX}-traefik-certs"
|
||||
docker volume rm "${PREFIX}-traefik-dynamic"
|
||||
docker volume rm "${PREFIX}-traefik-logs"
|
||||
docker volume rm "${PREFIX}-traefik-static"
|
||||
docker volume rm "${PREFIX}-webroot"
|
||||
fi
|
||||
25
purge.sh
25
purge.sh
@@ -1,25 +0,0 @@
|
||||
#! /bin/sh
|
||||
#
|
||||
|
||||
if [ -f ./.env ]
|
||||
then
|
||||
set -o allexport
|
||||
. ./.env
|
||||
set +o allexport
|
||||
else
|
||||
echo Missing .env file
|
||||
exit 1
|
||||
fi
|
||||
|
||||
read -p "Confirmation (YyOo) ? " REPLY
|
||||
if [ $(echo ${REPLY} | grep -i ^[yo]$) ]
|
||||
then
|
||||
docker-compose stop
|
||||
docker network disconnect $DOCKER_PREFIX $TRAEFIK_NETWORK_NAME
|
||||
docker network rm $DOCKER_PREFIX
|
||||
docker rm $DOCKER_PREFIX-adminer
|
||||
docker rm $DOCKER_PREFIX-web
|
||||
docker rm $DOCKER_PREFIX-db
|
||||
docker volume rm $DOCKER_PREFIX-web
|
||||
docker volume rm $DOCKER_PREFIX-db
|
||||
fi;
|
||||
42
replace-db.sh
Executable file
42
replace-db.sh
Executable file
@@ -0,0 +1,42 @@
|
||||
#! /bin/sh
|
||||
#
|
||||
|
||||
if [ "$#" -ne 1 ]; then
|
||||
echo "Usage: $0 <sql dump file>" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! [ -e "${1}" ]; then
|
||||
echo "$1 not found" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
set -a
|
||||
. "${PWD}/.env"
|
||||
set +a
|
||||
mkdir --parents "${PWD}/tmp"
|
||||
|
||||
dump_filename_path="${1}"
|
||||
|
||||
docker compose up db -d
|
||||
|
||||
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}-db" /bin/sh -c "mysqladmin ping -h 127.0.0.1 -P 3306 --protocol=tcp -u root -p${DB_ROOT_PASSWORD} --silent"; do
|
||||
echo "Waiting for the mysql server in ${PREFIX}-db to be up and running..."
|
||||
sleep 1
|
||||
done
|
||||
|
||||
echo "copying mysql dump to db container"
|
||||
docker cp "${dump_filename_path}" "${PREFIX}"-db:/tmp/dump.sql
|
||||
echo "dropping ${DB_NAME}"
|
||||
docker exec "${PREFIX}-db" /bin/sh -c "mysqladmin --force -uroot -p${DB_ROOT_PASSWORD} drop ${DB_NAME}"
|
||||
echo "creating ${DB_NAME}"
|
||||
docker exec "${PREFIX}-db" /bin/sh -c "mysqladmin -uroot -p${DB_ROOT_PASSWORD} create ${DB_NAME}"
|
||||
echo "run this command in another terminal/window to monitor progress:"
|
||||
echo "docker exec -it watch -n1 ${PREFIX}-db du /var/lib/mysql/${DB_NAME}-sh"
|
||||
echo "importing ${dump_filename_path} (${PREFIX}-db/tmp/dump.sql) into ${DB_NAME}"
|
||||
docker exec "${PREFIX}-db" /bin/sh -c "mysql -uroot -p${DB_ROOT_PASSWORD} ${DB_NAME} < /tmp/dump.sql"
|
||||
15
root.sh
15
root.sh
@@ -1,18 +1,11 @@
|
||||
#! /bin/sh
|
||||
#
|
||||
|
||||
if [ -f .env ]
|
||||
then
|
||||
set -o allexport;
|
||||
. ./.env;
|
||||
set +o allexport
|
||||
else
|
||||
echo Missing .env file
|
||||
exit 1
|
||||
fi
|
||||
set -a
|
||||
. "${PWD}/.env"
|
||||
set +a
|
||||
|
||||
docker exec \
|
||||
-it \
|
||||
--user root \
|
||||
${DOCKER_PREFIX}-web \
|
||||
--user root "${PREFIX}-app" \
|
||||
/bin/bash
|
||||
|
||||
24
start-ssh-tunnel.sh
Normal file
24
start-ssh-tunnel.sh
Normal file
@@ -0,0 +1,24 @@
|
||||
#! /bin/sh
|
||||
#
|
||||
|
||||
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/ssh-tunnel-example.env
|
||||
. "${1}"
|
||||
# shellcheck source=./.env-example
|
||||
. ./.env
|
||||
|
||||
ssh \
|
||||
-v \
|
||||
-N \
|
||||
-L \
|
||||
"${TRAEFIK_LISTENING_IP}:${LOCAL_PORT}:${LOCAL_IP_ON_REMOTE}:${LOCAL_PORT_ON_REMOTE}" \
|
||||
"${REMOTE_HOST}"
|
||||
11
traefik.sh
Executable file
11
traefik.sh
Executable file
@@ -0,0 +1,11 @@
|
||||
#! /bin/sh
|
||||
#
|
||||
|
||||
set -a;
|
||||
. "${PWD}/.env";
|
||||
set +a;
|
||||
|
||||
docker exec \
|
||||
-it \
|
||||
--user root "${PREFIX}-traefik" \
|
||||
/bin/ash
|
||||
22
umount-volumes.sh
Executable file
22
umount-volumes.sh
Executable file
@@ -0,0 +1,22 @@
|
||||
#! /bin/sh
|
||||
#
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo "must be ran as root"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
volumes="certs dynamic logs root static webroot"
|
||||
for volume in ${volumes}; do
|
||||
mount_path="${PWD}/traefik-volumes/${volume}"
|
||||
if [ "${volume}" = "webroot" ]; then
|
||||
mount_path="${PWD}/${volume}-volume"
|
||||
fi
|
||||
if [ "${volume}" = "root" ]; then
|
||||
mount_path="${PWD}/${volume}-volume"
|
||||
fi
|
||||
if mountpoint "${mount_path}" -q; then
|
||||
echo "umounting ${mount_path}"
|
||||
umount "${mount_path}"
|
||||
fi
|
||||
done
|
||||
18
wp.sh
18
wp.sh
@@ -1,18 +0,0 @@
|
||||
#! /bin/sh
|
||||
#
|
||||
|
||||
if [ -f .env ]
|
||||
then
|
||||
set -o allexport;
|
||||
. ./.env;
|
||||
set +o allexport
|
||||
else
|
||||
echo Missing .env file
|
||||
exit 1
|
||||
fi
|
||||
|
||||
docker exec \
|
||||
-it \
|
||||
--user www-data \
|
||||
${DOCKER_PREFIX}-web \
|
||||
/bin/bash
|
||||
Reference in New Issue
Block a user