diff --git a/docker-compose.yml b/docker-compose.yml index 937ceab28beefefbaf46291bd8b4f66489c04bc8..5c254809268fad1b7ec67933bf4c90d45661293e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,7 @@ version: '3.9' services: - nginx: + nginx-memo: image: nginx:stable-alpine container_name: nginx-memo volumes: @@ -9,7 +9,7 @@ services: - "./log:/var/log/nginx" - "./nginx.conf:/etc/nginx/nginx.conf:ro" ports: - - published: 80 + - published: 85 target: 80 networks: - databases @@ -17,6 +17,10 @@ services: php: build: dockerfile: dockerfile_php + depends_on: + - redis-memo + - postgresql-memo + - nginx-memo container_name: php-memo volumes: - "./www:/script" @@ -39,22 +43,26 @@ services: - "postgres_data:/var/lib/postgresql/data" networks: - databases - # command: echo "fuck" & - # command: psql -U user -d postgres -f postgresqldata/data/datapostgres.sql redis-memo: - image: redis:latest + build: + dockerfile: dockerfile_redis + restart: unless-stopped container_name: redis-memo ports: - published: 6379 target: 6379 volumes: - - ./www/data/redis_data:/redisdata/data:rw + - ./www/data/redis_data/taches.redis:/redisdata/data/taches.redis + - ./redis_rdb:/redisdata/rdb + - redis_data:/data networks: - databases + # command: redis-server --dbfilename dump.rdb --dir /data + - adminer: + adminer-memo: image: adminer restart: unless-stopped container_name: adminer-memo diff --git a/dockerfile_postgres b/dockerfile_postgres index 68cd1059e6e5e19a82114a80f9ab963745dcf8f2..28d01822031e3b8f55ecc663cef4c1a297c3093e 100644 --- a/dockerfile_postgres +++ b/dockerfile_postgres @@ -1,2 +1,3 @@ FROM postgres:latest + USER postgres \ No newline at end of file diff --git a/dockerfile_redis b/dockerfile_redis new file mode 100644 index 0000000000000000000000000000000000000000..5b324d8e8cf903c4c1df91250e7ee12d77de1b36 --- /dev/null +++ b/dockerfile_redis @@ -0,0 +1,4 @@ +FROM redis:latest + +COPY ./redis_rdb/dump.rdb /data/dump.rdb +COPY ./redis_rdb/test /data/test \ No newline at end of file diff --git a/redis_rdb/dump.rdb b/redis_rdb/dump.rdb new file mode 100644 index 0000000000000000000000000000000000000000..30b5c2920940059214b67fac60d3ad2ad1b3f6d3 Binary files /dev/null and b/redis_rdb/dump.rdb differ diff --git a/redis_rdb/test b/redis_rdb/test new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/www/data/memo.json b/www/data/memo.json index 7667064c0f4a52708233084e851bfb34ba6c029f..1609ee2b1be3138892e6d1ec160a9853fd4fb67e 100644 --- a/www/data/memo.json +++ b/www/data/memo.json @@ -1 +1 @@ -{"5defb94651ea3":{"texte":"finir le tp de prog web","accomplie":true,"dateAjout":"2019-12-10T15:27:02.000Z"},"5defb9a88e9a3":{"texte":"finir le tp d'animation ","accomplie":false,"dateAjout":"2019-12-10T15:28:40.000Z"},"5defbc36499e1":{"texte":"finir le tp de design","accomplie":true,"dateAjout":"2019-12-10T15:39:34.000Z"},"5defbc4b20c23":{"texte":"finir le tp de bdd","accomplie":false,"dateAjout":"2019-12-10T15:39:55.000Z"},"5defbc7418ff8":{"texte":"finir le tp de vid\u00e9o ","accomplie":true,"dateAjout":"2019-12-10T15:40:36.000Z"},"63763c41d6d4f":{"texte":"pr\u00e9parer la pr\u00e9sentation d'anglais","accomplie":true,"dateAjout":"2022-11-17 13:50:57"},"63764775e6206":{"texte":"finir projet nosql","accomplie":false,"dateAjout":"2022-11-17 14:38:45"},"637648750c469":{"texte":"finir projet web services","accomplie":false,"dateAjout":"2022-11-17 14:43:01"},"637648842e03f":{"texte":"appr\u00e9cier la puissance de docker","accomplie":false,"dateAjout":"2022-11-17 14:43:16"},"637652f339886":{"texte":"finir le projet nosql","accomplie":false,"dateAjout":"2022-11-17 15:27:47"},"6376543653b77":{"texte":"finir la pr\u00e9sentation en anglais","accomplie":false,"dateAjout":"2022-11-17 15:33:10"},"6376587328a8d":{"texte":"test","accomplie":false,"dateAjout":"2022-11-17 15:51:15"},"6376543154534":{"accomplie":true}} \ No newline at end of file +{"5defb94651ea3":{"texte":"finir le tp de prog web","accomplie":true,"dateAjout":"2019-12-10T15:27:02.000Z"},"5defb9a88e9a3":{"texte":"finir le tp d'animation ","accomplie":false,"dateAjout":"2019-12-10T15:28:40.000Z"},"5defbc36499e1":{"texte":"finir le tp de design","accomplie":true,"dateAjout":"2019-12-10T15:39:34.000Z"},"5defbc4b20c23":{"texte":"finir le tp de bdd","accomplie":false,"dateAjout":"2019-12-10T15:39:55.000Z"},"5defbc7418ff8":{"texte":"finir le tp de vid\u00e9o ","accomplie":true,"dateAjout":"2019-12-10T15:40:36.000Z"},"63763c41d6d4f":{"texte":"pr\u00e9parer la pr\u00e9sentation d'anglais","accomplie":true,"dateAjout":"2022-11-17 13:50:57"},"63764775e6206":{"texte":"finir projet nosql","accomplie":false,"dateAjout":"2022-11-17 14:38:45"},"637648750c469":{"texte":"finir projet web services","accomplie":false,"dateAjout":"2022-11-17 14:43:01"},"637648842e03f":{"texte":"appr\u00e9cier la puissance de docker","accomplie":false,"dateAjout":"2022-11-17 14:43:16"},"637652f339886":{"texte":"finir le projet nosql","accomplie":false,"dateAjout":"2022-11-17 15:27:47"},"6376543653b77":{"texte":"finir la pr\u00e9sentation en anglais","accomplie":true,"dateAjout":"2022-11-17 15:33:10"},"6376587328a8d":{"texte":"test","accomplie":false,"dateAjout":"2022-11-17 15:51:15"},"6376543154534":{"accomplie":false},"6376542bcaa53":{"accomplie":false},"6379276f2048f":{"texte":"test","accomplie":false,"dateAjout":"2022-11-19 18:58:55"},"63792c429807b":{"texte":"test","accomplie":false,"dateAjout":"2022-11-19 19:19:30"},"6379310f77d68":{"texte":"test","accomplie":false,"dateAjout":"2022-11-19 19:39:59"}} \ No newline at end of file diff --git a/www/data/redis_data/taches.redis b/www/data/redis_data/taches.redis new file mode 100644 index 0000000000000000000000000000000000000000..caa373a8b292b19dc812b8c0cdc82d253b96af01 --- /dev/null +++ b/www/data/redis_data/taches.redis @@ -0,0 +1,5 @@ +select 0 + +LPUSH 6376542bcaa53 "finir le projet de nosql" "0" "2022-11-17 15:32:59" +LPUSH 6376543653b77 "finir la présentation en anglais" "0" "2022-11-17 15:33:10" +LPUSH 6376543154534 "apprécier la puissance de docker" "0" "2022-11-17 15:33:05" diff --git a/www/index.php b/www/index.php index 3c2b2e0faa1dd7ee0cc365a099935835aa0bdd07..401aa30711268cd53ea923c5f5a5f808bafa5b5d 100644 --- a/www/index.php +++ b/www/index.php @@ -35,6 +35,9 @@ $db_connection = new PDO($config, $username, $password); $redis = new Redis(); $redis->connect('redis-memo', 6379); +$redisDbIdTaches = 0; +$redisDbIdChat = 1; + $tachesFichier = "data/memo.json"; $tachesJSON = file_get_contents($tachesFichier); @@ -91,7 +94,8 @@ if (isset($_POST["texteTache"])) { // Insert dans redis - + $redis->select($redisDbIdTaches); + $redis->rpush($idTache, $texte, 0, $dateHeureTache); } @@ -155,8 +159,10 @@ if (isset($_GET["action"]) && $_GET["action"]=="basculer" && isset($_GET["id"])) ]); // Basculer dans redis - + $redis->select($redisDbIdTaches); + $redis->lset($_GET["id"], 1, $tache["accomplie"] ? 0 : 1); + $tachesJSON = json_encode($tachesArray); file_put_contents($tachesFichier, $tachesJSON); @@ -176,7 +182,8 @@ if (isset($_GET["action"]) && $_GET["action"]=="supprimer" && isset($_GET["id"]) // Supprimer dans redis - + $redis->select($redisDbIdTaches); + $redis->del($_GET["id"]); $tachesJSON = json_encode($tachesArray); @@ -184,7 +191,7 @@ if (isset($_GET["action"]) && $_GET["action"]=="supprimer" && isset($_GET["id"]) file_put_contents($tachesFichier, $tachesJSON); } -$sql = "SELECT * FROM taches"; +$sql = "SELECT * FROM taches ORDER BY accomplie ASC, date_ajout DESC"; $stmt = $db_connection->prepare($sql); $stmt->execute(); $tachesArrayDb = $stmt->fetchAll(PDO::FETCH_ASSOC);