From fea56295305266cd387598437758322b3cb53f25 Mon Sep 17 00:00:00 2001 From: Matthieu LEMAIRE Date: Sun, 19 Oct 2025 19:02:25 +0200 Subject: [PATCH] Init project --- .idea/.gitignore | 8 +++++++ .idea/CMS-BTS-Ciel.iml | 9 ++++++++ .idea/misc.xml | 6 ++++++ .idea/modules.xml | 8 +++++++ .idea/vcs.xml | 6 ++++++ Dockerfile | 9 ++++++++ README.md | 48 ++++++++++++++++++++++++++++++++++++++++++ bdd/Dockerfile | 8 +++++++ bdd/init.sql | 3 +++ launch-dockers.sh | 25 ++++++++++++++++++++++ 10 files changed, 130 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/CMS-BTS-Ciel.iml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 Dockerfile create mode 100644 README.md create mode 100644 bdd/Dockerfile create mode 100644 bdd/init.sql create mode 100755 launch-dockers.sh diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/CMS-BTS-Ciel.iml b/.idea/CMS-BTS-Ciel.iml new file mode 100644 index 0000000..d6ebd48 --- /dev/null +++ b/.idea/CMS-BTS-Ciel.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..31e1ebc --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..1d1b251 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..0f39774 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,9 @@ +FROM php:8.2-apache +LABEL authors="matthieulmr" + +COPY . /var/www/html +WORKDIR /var/www/html + +RUN docker-php-ext-install pdo pdo_mysql + +EXPOSE 80 \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..223322c --- /dev/null +++ b/README.md @@ -0,0 +1,48 @@ +# Projet CMS Simplifié + +### Technologies utilisées + +Ce projet a été construit avec les technologies suivantes : + +![HTML5](https://img.shields.io/badge/HTML5-E34F26?style=for-the-badge&logo=html5&logoColor=white) +![CSS3](https://img.shields.io/badge/CSS3-1572B6?style=for-the-badge&logo=css3&logoColor=white) +![PHP](https://img.shields.io/badge/PHP-777BB4?style=for-the-badge&logo=php&logoColor=white) +![MySQL](https://img.shields.io/badge/MySQL-4479A1?style=for-the-badge&logo=mysql&logoColor=white) + +## Lancement des dockers MySql et Php + +### Création d'un réseau pour que les services docker puissent communiquer + +```bash +docker network create -d bridge CMS-bridge +``` + +### Build BDD + +Builder la BDD MySql avec le Dockerfile présent dans le répertoire bdd + +```bash +docker build -t cms_mysql . +``` + +Lancer l'image créée en le connectant au réseau précédemment créé + +```bash +docker run -d --name CMS_mysql -p 3306:3306 --network=CMS-bridge cms_mysql:latest +``` + +### Build PHP-Apache + +Builder PHP Apache avec le Dockerfile présent à la racine du projet + +```bash +docker build -t cms_php . +``` + +Lancer l'image créée en le connectant au réseau précédemment créé + +```bash +docker run -d --name CMS_php -p 8080:80 --network=CMS-bridge cms_php:latest +``` + +Pour éviter de lancer les commandes à chaque fois, un script launch-dockers.sh a executer en 'sudo' est disponible. \ No newline at end of file diff --git a/bdd/Dockerfile b/bdd/Dockerfile new file mode 100644 index 0000000..22e35ab --- /dev/null +++ b/bdd/Dockerfile @@ -0,0 +1,8 @@ +FROM mysql +LABEL authors="matthieulmr" + +ENV MYSQL_ROOT_PASSWORD='passwordRoot' + +COPY ./init.sql /docker-entrypoint-initdb.d/ + +EXPOSE 3306 \ No newline at end of file diff --git a/bdd/init.sql b/bdd/init.sql new file mode 100644 index 0000000..784b28a --- /dev/null +++ b/bdd/init.sql @@ -0,0 +1,3 @@ +CREATE DATABASE IF NOT EXISTS cms CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; + +USE cms; \ No newline at end of file diff --git a/launch-dockers.sh b/launch-dockers.sh new file mode 100755 index 0000000..e1eb597 --- /dev/null +++ b/launch-dockers.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +docker stop CMS_mysql + +docker stop CMS_php + +docker rm CMS_mysql + +docker rm CMS_php + +docker network rm CMS-bridge + +docker network create -d bridge CMS-bridge + +cd bdd + +docker build -t cms_mysql . + +docker run -d --name CMS_mysql -p 3306:3306 --network=CMS-bridge cms_mysql:latest + +cd .. + +docker build -t cms_php . + +docker run -d --name CMS_php -p 8080:80 --network=CMS-bridge cms_php:latest