From 43c45645c8c2c8c43e40bdf0f4ea45a1584ba073 Mon Sep 17 00:00:00 2001 From: Mohamed Menacer <mohamed.menacer@etu.univ-amu.fr> Date: Mon, 10 Mar 2025 00:57:38 +0100 Subject: [PATCH 01/13] test4 --- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 76e8194..0e756fd 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -28,6 +28,7 @@ run_tests: stage: test image: php:$PHP_VERSION script: + - chmod +x bin/phpunit # Ajoute cette ligne - ./bin/phpunit # Déploiement (à adapter selon ton serveur) -- GitLab From e65592db44cee4fc3a379e0f7ab5f228ed8a09a3 Mon Sep 17 00:00:00 2001 From: Mohamed Menacer <mohamed.menacer@etu.univ-amu.fr> Date: Mon, 10 Mar 2025 01:02:28 +0100 Subject: [PATCH 02/13] test5 --- .gitlab-ci.yml | 47 ++++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0e756fd..b82f4aa 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,41 +1,42 @@ -stages: - - install - - test - - deploy # Optionnel, à activer si nécessaire +image: docker:latest + +services: + - docker:dind variables: + DOCKER_DRIVER: overlay2 PHP_VERSION: "8.2" COMPOSER_CACHE_DIR: "$CI_PROJECT_DIR/var/cache/composer" +stages: + - build + - test + cache: key: composer paths: - vendor/ - var/cache/composer/ -install_dependencies: - stage: install - image: php:$PHP_VERSION +before_script: + - apk add --no-cache bash git unzip curl docker-compose + - docker --version + - docker-compose --version + +build: + stage: build script: - - apt-get update && apt-get install -y unzip git - - curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer - - composer install --no-interaction --prefer-dist + - docker-compose up -d + - docker-compose exec php composer install --no-interaction --prefer-dist artifacts: paths: - vendor/ -run_tests: +test: stage: test - image: php:$PHP_VERSION script: - - chmod +x bin/phpunit # Ajoute cette ligne - - ./bin/phpunit - -# Déploiement (à adapter selon ton serveur) -deploy: - stage: deploy - only: - - main # Modifier selon la branche utilisée - script: - - echo "Déploiement en cours..." - # Ajouter ici les commandes pour le déploiement + - docker-compose exec php chmod +x bin/phpunit + - docker-compose exec php ./bin/phpunit + dependencies: + - build + -- GitLab From 898754d25cc9d69de0e027ab08ffb7843917c5e6 Mon Sep 17 00:00:00 2001 From: Mohamed Menacer <mohamed.menacer@etu.univ-amu.fr> Date: Mon, 10 Mar 2025 01:05:59 +0100 Subject: [PATCH 03/13] test6 --- .gitlab-ci.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b82f4aa..0532b78 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,10 +1,13 @@ image: docker:latest services: - - docker:dind + - name: docker:dind + command: ["--tls=false"] + privileged: true variables: - DOCKER_DRIVER: overlay2 + DOCKER_HOST: tcp://localhost:2375 + DOCKER_TLS_CERTDIR: "" PHP_VERSION: "8.2" COMPOSER_CACHE_DIR: "$CI_PROJECT_DIR/var/cache/composer" -- GitLab From fd8a15358fbabc80c9ad426f427db23e969d3eb7 Mon Sep 17 00:00:00 2001 From: Mohamed Menacer <mohamed.menacer@etu.univ-amu.fr> Date: Mon, 10 Mar 2025 01:07:26 +0100 Subject: [PATCH 04/13] test7 --- .gitlab-ci.yml | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0532b78..4ccde4e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,12 +1,10 @@ -image: docker:latest +image: docker:26.1 # Assure-toi d'utiliser une version stable de Docker services: - - name: docker:dind - command: ["--tls=false"] - privileged: true + - docker:26.1-dind # Démarre Docker-in-Docker variables: - DOCKER_HOST: tcp://localhost:2375 + DOCKER_HOST: tcp://docker:2375 DOCKER_TLS_CERTDIR: "" PHP_VERSION: "8.2" COMPOSER_CACHE_DIR: "$CI_PROJECT_DIR/var/cache/composer" @@ -15,21 +13,15 @@ stages: - build - test -cache: - key: composer - paths: - - vendor/ - - var/cache/composer/ - before_script: - apk add --no-cache bash git unzip curl docker-compose - - docker --version - - docker-compose --version + - docker info # Vérifie si Docker fonctionne + - docker-compose version # Vérifie si Docker Compose est bien installé build: stage: build script: - - docker-compose up -d + - docker-compose up -d # Démarre tes services - docker-compose exec php composer install --no-interaction --prefer-dist artifacts: paths: -- GitLab From 8df759fb326f14ff197c1924f1694ebb4bd25c4c Mon Sep 17 00:00:00 2001 From: Mohamed Menacer <mohamed.menacer@etu.univ-amu.fr> Date: Mon, 10 Mar 2025 01:11:22 +0100 Subject: [PATCH 05/13] test8 --- .gitlab-ci.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4ccde4e..b64ec6e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,11 +1,12 @@ -image: docker:26.1 # Assure-toi d'utiliser une version stable de Docker +image: docker:26.1 # Utilisation de Docker stable services: - - docker:26.1-dind # Démarre Docker-in-Docker + - name: docker:26.1-dind + command: ["--tls=false"] variables: - DOCKER_HOST: tcp://docker:2375 - DOCKER_TLS_CERTDIR: "" + DOCKER_HOST: tcp://127.0.0.1:2375 # ✅ Corrige l'accès au daemon Docker + DOCKER_TLS_CERTDIR: "" # ✅ Désactive le mode TLS PHP_VERSION: "8.2" COMPOSER_CACHE_DIR: "$CI_PROJECT_DIR/var/cache/composer" @@ -15,13 +16,13 @@ stages: before_script: - apk add --no-cache bash git unzip curl docker-compose - - docker info # Vérifie si Docker fonctionne - - docker-compose version # Vérifie si Docker Compose est bien installé + - docker info # ✅ Vérifie si Docker fonctionne + - docker-compose version build: stage: build script: - - docker-compose up -d # Démarre tes services + - docker-compose up -d # ✅ Démarre les services - docker-compose exec php composer install --no-interaction --prefer-dist artifacts: paths: @@ -34,4 +35,3 @@ test: - docker-compose exec php ./bin/phpunit dependencies: - build - -- GitLab From 0ce8d983820c51ce337c3bb2702769823699ad34 Mon Sep 17 00:00:00 2001 From: Mohamed Menacer <mohamed.menacer@etu.univ-amu.fr> Date: Mon, 10 Mar 2025 01:14:43 +0100 Subject: [PATCH 06/13] test9 --- .gitlab-ci.yml | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b64ec6e..3e1008c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,12 +1,7 @@ image: docker:26.1 # Utilisation de Docker stable -services: - - name: docker:26.1-dind - command: ["--tls=false"] - variables: - DOCKER_HOST: tcp://127.0.0.1:2375 # ✅ Corrige l'accès au daemon Docker - DOCKER_TLS_CERTDIR: "" # ✅ Désactive le mode TLS + DOCKER_HOST: unix:///var/run/docker.sock # ✅ Utilisation du Docker du runner PHP_VERSION: "8.2" COMPOSER_CACHE_DIR: "$CI_PROJECT_DIR/var/cache/composer" @@ -16,8 +11,8 @@ stages: before_script: - apk add --no-cache bash git unzip curl docker-compose - - docker info # ✅ Vérifie si Docker fonctionne - - docker-compose version + - docker version # ✅ Vérifie si Docker est bien accessible + - docker-compose version # ✅ Vérifie si Docker Compose fonctionne build: stage: build -- GitLab From 914912ac06573c79e3ac1368ce7c881cb6235aef Mon Sep 17 00:00:00 2001 From: Mohamed Menacer <mohamed.menacer@etu.univ-amu.fr> Date: Mon, 10 Mar 2025 01:26:22 +0100 Subject: [PATCH 07/13] test10 --- .gitlab-ci.yml | 52 ++++++++++++++++++++++++++++++++------------------ 1 file changed, 33 insertions(+), 19 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3e1008c..79a88d7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,32 +1,46 @@ -image: docker:26.1 # Utilisation de Docker stable - -variables: - DOCKER_HOST: unix:///var/run/docker.sock # ✅ Utilisation du Docker du runner - PHP_VERSION: "8.2" - COMPOSER_CACHE_DIR: "$CI_PROJECT_DIR/var/cache/composer" +image: docker:latest +# Définition des stages stages: - build - test + - deploy -before_script: - - apk add --no-cache bash git unzip curl docker-compose - - docker version # ✅ Vérifie si Docker est bien accessible - - docker-compose version # ✅ Vérifie si Docker Compose fonctionne +# Variables d'environnement, si nécessaires pour Docker Compose +variables: + DOCKER_DRIVER: overlay2 + COMPOSE_FILE: "docker-compose.yml" +# Job pour construire l'image Docker avec Docker Compose build: stage: build + services: + - docker:19.03.12-dind script: - - docker-compose up -d # ✅ Démarre les services - - docker-compose exec php composer install --no-interaction --prefer-dist - artifacts: - paths: - - vendor/ + - docker-compose -f $COMPOSE_FILE build + - docker-compose -f $COMPOSE_FILE up -d +# Job de tests test: stage: test + services: + - docker:19.03.12-dind + script: + - docker-compose -f $COMPOSE_FILE exec php composer install + - docker-compose -f $COMPOSE_FILE exec php vendor/bin/phpunit + after_script: + - docker-compose -f $COMPOSE_FILE down + +# Job de déploiement +deploy: + stage: deploy + script: + - echo "Déploiement de l'application..." # Remplacer par tes propres commandes de déploiement + when: manual # Pour déployer manuellement + +# Job pour nettoyer les containers +cleanup: + stage: cleanup script: - - docker-compose exec php chmod +x bin/phpunit - - docker-compose exec php ./bin/phpunit - dependencies: - - build + - docker-compose -f $COMPOSE_FILE down + when: always -- GitLab From d52dc7d813995bdd90a9140b3903894edfe7e5e6 Mon Sep 17 00:00:00 2001 From: Mohamed Menacer <mohamed.menacer@etu.univ-amu.fr> Date: Mon, 10 Mar 2025 01:27:31 +0100 Subject: [PATCH 08/13] test11 --- .gitlab-ci.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 79a88d7..b3a7921 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -5,6 +5,7 @@ stages: - build - test - deploy + - .post # Ajout de la stage .post pour le nettoyage # Variables d'environnement, si nécessaires pour Docker Compose variables: @@ -38,9 +39,9 @@ deploy: - echo "Déploiement de l'application..." # Remplacer par tes propres commandes de déploiement when: manual # Pour déployer manuellement -# Job pour nettoyer les containers +# Job pour nettoyer les containers (modifié pour être dans la stage .post) cleanup: - stage: cleanup + stage: .post # Utilisation de la stage .post script: - docker-compose -f $COMPOSE_FILE down when: always -- GitLab From cbc49e8c6f063e2d55dc07da34fef589777255ae Mon Sep 17 00:00:00 2001 From: Mohamed Menacer <mohamed.menacer@etu.univ-amu.fr> Date: Mon, 10 Mar 2025 01:29:41 +0100 Subject: [PATCH 09/13] test12 --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b3a7921..948998d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -10,7 +10,7 @@ stages: # Variables d'environnement, si nécessaires pour Docker Compose variables: DOCKER_DRIVER: overlay2 - COMPOSE_FILE: "docker-compose.yml" + COMPOSE_FILE: "compose.yaml" # Job pour construire l'image Docker avec Docker Compose build: -- GitLab From 17ce3933eaa7d6f1b55932f713a729298d341084 Mon Sep 17 00:00:00 2001 From: Mohamed Menacer <mohamed.menacer@etu.univ-amu.fr> Date: Mon, 10 Mar 2025 01:36:12 +0100 Subject: [PATCH 10/13] test12 --- .gitlab-ci.yml | 44 +++++++++----------------------------------- 1 file changed, 9 insertions(+), 35 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 948998d..8c2f2bb 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,47 +1,21 @@ image: docker:latest -# Définition des stages +services: + - name: docker:19.03.12 + alias: docker + +variables: + DOCKER_DRIVER: overlay2 + COMPOSE_FILE: "docker-compose.yml" + DOCKER_HOST: "tcp://docker:2375" # Peut être omis si Docker est installé sur l'hôte. + stages: - build - test - deploy - - .post # Ajout de la stage .post pour le nettoyage - -# Variables d'environnement, si nécessaires pour Docker Compose -variables: - DOCKER_DRIVER: overlay2 - COMPOSE_FILE: "compose.yaml" -# Job pour construire l'image Docker avec Docker Compose build: stage: build - services: - - docker:19.03.12-dind script: - docker-compose -f $COMPOSE_FILE build - docker-compose -f $COMPOSE_FILE up -d - -# Job de tests -test: - stage: test - services: - - docker:19.03.12-dind - script: - - docker-compose -f $COMPOSE_FILE exec php composer install - - docker-compose -f $COMPOSE_FILE exec php vendor/bin/phpunit - after_script: - - docker-compose -f $COMPOSE_FILE down - -# Job de déploiement -deploy: - stage: deploy - script: - - echo "Déploiement de l'application..." # Remplacer par tes propres commandes de déploiement - when: manual # Pour déployer manuellement - -# Job pour nettoyer les containers (modifié pour être dans la stage .post) -cleanup: - stage: .post # Utilisation de la stage .post - script: - - docker-compose -f $COMPOSE_FILE down - when: always -- GitLab From 07276ca519bcbdb520b7c7ab66e2675ff7e31b8f Mon Sep 17 00:00:00 2001 From: Mohamed Menacer <mohamed.menacer@etu.univ-amu.fr> Date: Mon, 10 Mar 2025 01:37:09 +0100 Subject: [PATCH 11/13] test14 --- .gitlab-ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8c2f2bb..6495777 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -7,13 +7,15 @@ services: variables: DOCKER_DRIVER: overlay2 COMPOSE_FILE: "docker-compose.yml" - DOCKER_HOST: "tcp://docker:2375" # Peut être omis si Docker est installé sur l'hôte. stages: - build - test - deploy +before_script: + - export DOCKER_HOST="unix:///var/run/docker.sock" # Utilisation du socket Docker de l'hôte + build: stage: build script: -- GitLab From d994e998aa2ea726e38c049d2365389429d3f979 Mon Sep 17 00:00:00 2001 From: Mohamed Menacer <mohamed.menacer@etu.univ-amu.fr> Date: Mon, 10 Mar 2025 01:37:44 +0100 Subject: [PATCH 12/13] test15 --- .gitlab-ci.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6495777..064637f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,12 +1,13 @@ image: docker:latest +# Aucune utilisation de "docker:dind" services: - - name: docker:19.03.12 - alias: docker + - docker:19.03.12 variables: DOCKER_DRIVER: overlay2 COMPOSE_FILE: "docker-compose.yml" + DOCKER_HOST: "unix:///var/run/docker.sock" # Utilisation du socket Docker de l'hôte. stages: - build @@ -14,7 +15,7 @@ stages: - deploy before_script: - - export DOCKER_HOST="unix:///var/run/docker.sock" # Utilisation du socket Docker de l'hôte + - export DOCKER_HOST="unix:///var/run/docker.sock" # Connexion à Docker sur l'hôte build: stage: build -- GitLab From 7924b94f4cadde72f46e83f7c389230ff2eb6edd Mon Sep 17 00:00:00 2001 From: Mohamed Menacer <mohamed.menacer@etu.univ-amu.fr> Date: Wed, 12 Mar 2025 02:19:40 +0100 Subject: [PATCH 13/13] final version --- .gitlab-ci.yml | 24 ----------------- compose.yaml | 2 +- docker/php/Dockerfile | 3 +-- migrations/Version20250312002806.php | 33 +++++++++++++++++++++++ src/Controller/RegistrationController.php | 2 +- 5 files changed, 36 insertions(+), 28 deletions(-) delete mode 100644 .gitlab-ci.yml create mode 100644 migrations/Version20250312002806.php diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index 064637f..0000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,24 +0,0 @@ -image: docker:latest - -# Aucune utilisation de "docker:dind" -services: - - docker:19.03.12 - -variables: - DOCKER_DRIVER: overlay2 - COMPOSE_FILE: "docker-compose.yml" - DOCKER_HOST: "unix:///var/run/docker.sock" # Utilisation du socket Docker de l'hôte. - -stages: - - build - - test - - deploy - -before_script: - - export DOCKER_HOST="unix:///var/run/docker.sock" # Connexion à Docker sur l'hôte - -build: - stage: build - script: - - docker-compose -f $COMPOSE_FILE build - - docker-compose -f $COMPOSE_FILE up -d diff --git a/compose.yaml b/compose.yaml index 70d3c49..f5f03db 100644 --- a/compose.yaml +++ b/compose.yaml @@ -15,7 +15,7 @@ services: build: ./docker/nginx volumes: - ./public:/var/www/public:delegated - - ./docker/nginx/nginx.conf:/etc/nginx/conf.d/default.conf + - ./docker/nginx/nginx.conf:/etc/nginx/default.conf ports: - "8000:80" depends_on: #sinon on sera pas interprété les requêtes diff --git a/docker/php/Dockerfile b/docker/php/Dockerfile index d27b8e6..0c64465 100644 --- a/docker/php/Dockerfile +++ b/docker/php/Dockerfile @@ -1,7 +1,6 @@ # l'image php c'est une image minimaliste qui ne va inclure toutes les extenctions importantes pour fonctionner avec Symphony # par exemple Ctype, iconv, simpleXML, Session .. - -FROM PHP:8.3-fpm-alpine +FROM php:8.3-fpm-alpine # install dependencies ' permet d installer des differentes dependances ' RUN apk --no-cache add curl git wget bash dpkg diff --git a/migrations/Version20250312002806.php b/migrations/Version20250312002806.php new file mode 100644 index 0000000..3be2103 --- /dev/null +++ b/migrations/Version20250312002806.php @@ -0,0 +1,33 @@ +<?php + +declare(strict_types=1); + +namespace DoctrineMigrations; + +use Doctrine\DBAL\Schema\Schema; +use Doctrine\Migrations\AbstractMigration; + +/** + * Auto-generated Migration: Please modify to your needs! + */ +final class Version20250312002806 extends AbstractMigration +{ + public function getDescription(): string + { + return ''; + } + + public function up(Schema $schema): void + { + // this up() migration is auto-generated, please modify it to your needs + $this->addSql('CREATE TABLE `user` (id INT AUTO_INCREMENT NOT NULL, email VARCHAR(180) NOT NULL, roles JSON NOT NULL COMMENT \'(DC2Type:json)\', password VARCHAR(255) NOT NULL, is_verified TINYINT(1) NOT NULL, UNIQUE INDEX UNIQ_IDENTIFIER_EMAIL (email), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + $this->addSql('CREATE TABLE messenger_messages (id BIGINT AUTO_INCREMENT NOT NULL, body LONGTEXT NOT NULL, headers LONGTEXT NOT NULL, queue_name VARCHAR(190) NOT NULL, created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', available_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', delivered_at DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\', INDEX IDX_75EA56E0FB7336F0 (queue_name), INDEX IDX_75EA56E0E3BD61CE (available_at), INDEX IDX_75EA56E016BA31DB (delivered_at), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('DROP TABLE `user`'); + $this->addSql('DROP TABLE messenger_messages'); + } +} diff --git a/src/Controller/RegistrationController.php b/src/Controller/RegistrationController.php index 3e8a71f..77c0001 100644 --- a/src/Controller/RegistrationController.php +++ b/src/Controller/RegistrationController.php @@ -89,6 +89,6 @@ class RegistrationController extends AbstractController // @TODO Change the redirect on success and handle or remove the flash message in your templates $this->addFlash('success', 'Your email address has been verified.'); - return $this->redirectToRoute('app_register'); + return $this->redirectToRoute('app_login'); } } -- GitLab