From ac5a3493e7a8dbeab51082ad4651bd505afe4c25 Mon Sep 17 00:00:00 2001 From: tristan Date: Thu, 22 Jan 2026 16:36:46 +0100 Subject: [PATCH] =?UTF-8?q?fix=20:=20doc=20et=20script=20de=20d=C3=A9ploie?= =?UTF-8?q?ment?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/workspace.xml | 20 +++++++++++++++----- DEPLOYMENT.md | 14 ++++++++++++-- README.md | 4 ++-- scripts/deploy-release.sh | 13 +------------ 4 files changed, 30 insertions(+), 21 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 36e1632..e9d401d 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -4,9 +4,11 @@ - @@ -542,7 +551,8 @@ - diff --git a/DEPLOYMENT.md b/DEPLOYMENT.md index 33ff48d..c2b83ca 100644 --- a/DEPLOYMENT.md +++ b/DEPLOYMENT.md @@ -68,10 +68,20 @@ 1. Créer un tag sur `develop` (auto-tag `v0.0.X`) 2. Attendre que la release Gitea soit publiée -3. Déployer la release +3. (Une seule fois) Donner les droits d'écriture à PHP sur `var/` via ACL ```bash - sudo DEPLOY_OWNER=malio DEPLOY_GROUP=www-data /usr/local/bin/deploy-ferme v0.0.X + sudo apt update + sudo apt install -y acl + sudo setfacl -R -m u:malio:rwx,g:www-data:rwx /var/www/ferme/var + sudo setfacl -R -m d:u:malio:rwx,d:g:www-data:rwx /var/www/ferme/var ``` +4. Déployer la release + ```bash + /usr/local/bin/deploy-ferme vX.Y.Z + ``` + Notes : + - Lancer le déploiement en tant que `malio` (ou `sudo -u malio`) pour éviter de casser les droits. + - Le script applique `umask 002` pour garder les fichiers group-writable (`www-data`). ### Vérifications - Front : `http://ferme.malio-dev.fr/` diff --git a/README.md b/README.md index 02e2eab..20bbaee 100644 --- a/README.md +++ b/README.md @@ -82,8 +82,8 @@ Sur la machine, il est disponible dans /usr/local/bin/deploy-ferme
Pour le modifier, il faut copier le contenu du deploy-release.sh dans le deploy-ferme ### Livraison Sur le serveur de recette, il suffit d'utiliser cette commande pour livrer -```bash -sudo DEPLOY_OWNER=malio DEPLOY_GROUP=www-data ./scripts/deploy-release.sh vX.Y.Z +```bash +/usr/local/bin/deploy-ferme vX.Y.Z ``` ## Commandes utiles Pour restart le container diff --git a/scripts/deploy-release.sh b/scripts/deploy-release.sh index bc24ff4..4af8883 100644 --- a/scripts/deploy-release.sh +++ b/scripts/deploy-release.sh @@ -5,6 +5,7 @@ set -euo pipefail # Requires: curl, tar, (optional) rsync # # Auth token: set RELEASE_TOKEN env var or create /etc/ferme-release-token +umask 002 TAG="${1:-}" if [ -z "$TAG" ]; then @@ -71,18 +72,6 @@ fi echo "Release ${TAG} deployed to ${DEPLOY_DIR}" -if [ -n "${DEPLOY_OWNER:-}" ]; then - DEPLOY_GROUP="${DEPLOY_GROUP:-www-data}" - DEPLOY_PERMS_SCOPE="${DEPLOY_PERMS_SCOPE:-var}" - if [ "$DEPLOY_PERMS_SCOPE" = "all" ]; then - chown -R "${DEPLOY_OWNER}:${DEPLOY_GROUP}" "$DEPLOY_DIR" - chmod -R g+rx,o+rx "$DEPLOY_DIR" - elif [ -d "${DEPLOY_DIR}/var" ]; then - chown -R "${DEPLOY_OWNER}:${DEPLOY_GROUP}" "${DEPLOY_DIR}/var" - chmod -R g+rwX "${DEPLOY_DIR}/var" - fi -fi - if [ -f "${DEPLOY_DIR}/.env.local" ]; then echo "Running migrations (if any)..." php "${DEPLOY_DIR}/bin/console" doctrine:migrations:migrate --no-interaction --env=prod