From 692ec436a52a92b42efa958bd6c5285580a3fe9c Mon Sep 17 00:00:00 2001 From: ineszang44 Date: Thu, 17 Sep 2026 11:28:22 +0200 Subject: [PATCH] =?UTF-8?q?feat+chore(frontend):=20d=C3=A9ploiement=20selo?= =?UTF-8?q?n=20l'env=20s=C3=A9lectionn=C3=A9,=20commentaires=20sur=20le=20?= =?UTF-8?q?fichier=20terraform?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- infra/terraform/environments/dev/frontend.tf | 28 ++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/infra/terraform/environments/dev/frontend.tf b/infra/terraform/environments/dev/frontend.tf index c72cd87..8460459 100644 --- a/infra/terraform/environments/dev/frontend.tf +++ b/infra/terraform/environments/dev/frontend.tf @@ -1,13 +1,37 @@ +locals { + frontend_environments = { + dev = { + source_dir = "${path.root}/../../../apps/frontend/dist/frontend-dev/browser" + domain = "dev.enervision" + } + + rec = { + source_dir = "${path.root}/../../../apps/frontend/dist/frontend-rec/browser" + domain = "rec.enervision" + } + + prod = { + source_dir = "${path.root}/../../../apps/frontend/dist/frontend-prod/browser" + domain = "enervision" + } + } + + selected_frontend = local.frontend_environments[var.deployment_environment] +} + resource "null_resource" "frontend" { depends_on = [module.k3s] triggers = { + environment = var.deployment_environment + build_hash = sha256(join("", [ for file in fileset("${path.root}/../../../apps/frontend/dist/frontend/browser", "**") : filesha256("${path.root}/../../../apps/frontend/dist/frontend/browser/${file}") ])) } + // Variables pour la connexion SSH connection { type = "ssh" host = var.ssh_host @@ -16,6 +40,8 @@ resource "null_resource" "frontend" { private_key = file(pathexpand(var.ssh_private_key_path)) } + // Lancement de script en SSH avec remote-exec + // Installation de Nginx et initialisation du répertoire du frontend provisioner "remote-exec" { inline = [ "sudo apt-get update", @@ -25,11 +51,13 @@ resource "null_resource" "frontend" { ] } + // Copie des fichiers vers le serveur provisioner "file" { source = "${path.root}/../../../apps/frontend/dist/frontend/browser/" destination = "/tmp/enervision-frontend" } + // Déplacement des fichiers provisioner "remote-exec" { inline = [ "sudo cp -r /tmp/enervision-frontend/* /var/www/enervision/",