From c8a37d469df93c56c181f32c859dcb53cb2bb03c Mon Sep 17 00:00:00 2001 From: Florentin Labelle <florentin.labelle@student-cs.fr> Date: Wed, 12 Oct 2022 10:28:49 +0200 Subject: [PATCH] Deploy automatically --- .gitlab-ci.yml | 13 +++++++++++++ deploy/setup.md | 12 +++++++----- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e62c428..fc72982 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -4,6 +4,7 @@ stages: - dependencies - lint - test + - deploy download_dependencies: stage: dependencies @@ -38,3 +39,15 @@ pytest: - source .venv/bin/activate script: - pytest calculator + +# deploy: +# stage: deploy +# needs: +# - pylint +# - pytest +# before_script: +# - apt-get update +# - apt-get install -y openssh-client sshpass +# script: +# - sshpass -p labellefl ssh -o StrictHostKeyChecking=no labellefl@138.195.138.142 +# "cd /var/www/cicd && git pull && sudo systemctl restart calculator" diff --git a/deploy/setup.md b/deploy/setup.md index 7ab3d03..83e5287 100644 --- a/deploy/setup.md +++ b/deploy/setup.md @@ -17,13 +17,15 @@ pip install -r requirements.txt ## Ajoute le service +Un service c'est une application qui tourne en tâche de fond sur la machine. On va créer un service pour notre application. Un service est un fichier qui se trouve dans `/etc/systemd/system/` et qui s'appelle `quelquechose.service`. On a déjà crée le fichier pour vous, vous n'avez plus qu'à le copier dans le bon dossier. + ```bash -cp deploy/calculator.service /etc/systemd/system/ -systemctl daemon-reload -systemctl enable calculator -systemctl start calculator +sudo cp deploy/calculator.service /etc/systemd/system/ +sudo systemctl daemon-reload +sudo systemctl enable calculator +sudo systemctl start calculator ``` ## Dans ton navigateur -- "http://ip-de-la-vm:80/" +- "http://ip-de-la-vm/" -- GitLab