commit 1fcedfa03fb6d25900764cc46f4838a736b9918a Author: Jephte Clain Date: Mon Feb 10 07:08:21 2025 +0400 importation initiale diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9edf57a --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.~lock*# +.*.swp diff --git a/docker-compose/p1/Dockerfile b/docker-compose/p1/Dockerfile new file mode 100644 index 0000000..693ba65 --- /dev/null +++ b/docker-compose/p1/Dockerfile @@ -0,0 +1,4 @@ +FROM php:8.2-apache + +RUN docker-php-ext-install pdo pdo_mysql && \ + docker-php-ext-enable pdo_mysql diff --git a/docker-compose/p1/docker-compose.yml b/docker-compose/p1/docker-compose.yml new file mode 100644 index 0000000..751e1db --- /dev/null +++ b/docker-compose/p1/docker-compose.yml @@ -0,0 +1,33 @@ +# -*- coding: utf-8 mode: yaml -*- vim:sw=2:sts=2:et:ai:si:sta:fenc=utf-8 + +services: + db: + image: mariadb:10 + environment: + MARIADB_ROOT_PASSWORD: admin + MARIADB_DATABASE: mydb + MARIADB_USER: myuser + MARIADB_PASSWORD: pass + volumes: + - data:/var/lib/mysql + - ./initdb:/docker-entrypoint-initdb.d + restart: always + + adminer: + image: adminer + ports: + - 8082:8080 + restart: always + + web: + build: . + volumes: + - logs:/var/log/apache2 + - ./public:/var/www/html + ports: + - 8081:80 + restart: always + +volumes: + data: + logs: diff --git a/docker-compose/p1/initdb/visit.sql b/docker-compose/p1/initdb/visit.sql new file mode 100644 index 0000000..c627fa1 --- /dev/null +++ b/docker-compose/p1/initdb/visit.sql @@ -0,0 +1,7 @@ +-- -*- coding: utf-8 mode: sql -*- vim:sw=4:sts=4:et:ai:si:sta:fenc= + +create table visit ( + id integer primary key auto_increment, + ts timestamp, + url varchar(256) +); diff --git a/docker-compose/p1/public/index.php b/docker-compose/p1/public/index.php new file mode 100644 index 0000000..6fb814b --- /dev/null +++ b/docker-compose/p1/public/index.php @@ -0,0 +1,30 @@ +prepare("insert into visit(ts, url) values (now(), :url)"); +$st->execute([ + "url" => $_SERVER["SCRIPT_NAME"], +]); + +$st = $pdo->query("select count(*) count from visit"); +$count = $st->fetch()["count"]; + +?> + +prout + + +

prout

+

Nombre de visites:

+ + + diff --git a/docker-compose/p1/public/info.php b/docker-compose/p1/public/info.php new file mode 100644 index 0000000..c4837a3 --- /dev/null +++ b/docker-compose/p1/public/info.php @@ -0,0 +1 @@ + + # The ServerName directive sets the request scheme, hostname and port that + # the server uses to identify itself. This is used when creating + # redirection URLs. In the context of virtual hosts, the ServerName + # specifies what hostname must appear in the request's Host: header to + # match this virtual host. For the default virtual host (this file) this + # value is not decisive as it is used as a last resort host regardless. + # However, you must set it for any further virtual host explicitly. + #ServerName www.example.com + + ServerAdmin webmaster@localhost + DocumentRoot /var/www/html + + + ProxyPass http://adminer:8080/ + ProxyPassReverse http://adminer:8080/ + RequestHeader add X-Forwarded-Prefix /adminer + + + # Available loglevels: trace8, ..., trace1, debug, info, notice, warn, + # error, crit, alert, emerg. + # It is also possible to configure the loglevel for particular + # modules, e.g. + #LogLevel info ssl:warn + + ErrorLog ${APACHE_LOG_DIR}/error.log + CustomLog ${APACHE_LOG_DIR}/access.log combined + + # For most configuration files from conf-available/, which are + # enabled or disabled at a global level, it is possible to + # include a line for only one particular virtual host. For example the + # following line enables the CGI configuration for this host only + # after it has been globally disabled with "a2disconf". + #Include conf-available/serve-cgi-bin.conf + diff --git a/docker-compose/p2/docker-compose.yml b/docker-compose/p2/docker-compose.yml new file mode 100644 index 0000000..c77d5a8 --- /dev/null +++ b/docker-compose/p2/docker-compose.yml @@ -0,0 +1,41 @@ +# -*- coding: utf-8 mode: yaml -*- vim:sw=2:sts=2:et:ai:si:sta:fenc=utf-8 + +services: + db: + image: mariadb:10 + environment: + MARIADB_ROOT_PASSWORD: admin + MARIADB_DATABASE: mydb + MARIADB_USER: myuser + MARIADB_PASSWORD: pass + volumes: + - data:/var/lib/mysql + - ./initdb:/docker-entrypoint-initdb.d + networks: + - int + restart: always + + adminer: + image: adminer + networks: + - int + restart: always + + web: + build: . + volumes: + - logs:/var/log/apache2 + - ./public:/var/www/html + networks: + - default + - int + ports: + - 8083:80 + restart: always + +volumes: + data: + logs: + +networks: + int: diff --git a/docker-compose/p2/initdb/visit.sql b/docker-compose/p2/initdb/visit.sql new file mode 100644 index 0000000..c627fa1 --- /dev/null +++ b/docker-compose/p2/initdb/visit.sql @@ -0,0 +1,7 @@ +-- -*- coding: utf-8 mode: sql -*- vim:sw=4:sts=4:et:ai:si:sta:fenc= + +create table visit ( + id integer primary key auto_increment, + ts timestamp, + url varchar(256) +); diff --git a/docker-compose/p2/public/index.php b/docker-compose/p2/public/index.php new file mode 100644 index 0000000..6fb814b --- /dev/null +++ b/docker-compose/p2/public/index.php @@ -0,0 +1,30 @@ +prepare("insert into visit(ts, url) values (now(), :url)"); +$st->execute([ + "url" => $_SERVER["SCRIPT_NAME"], +]); + +$st = $pdo->query("select count(*) count from visit"); +$count = $st->fetch()["count"]; + +?> + +prout + + +

prout

+

Nombre de visites:

+ + + diff --git a/docker-compose/p2/public/info.php b/docker-compose/p2/public/info.php new file mode 100644 index 0000000..c4837a3 --- /dev/null +++ b/docker-compose/p2/public/info.php @@ -0,0 +1 @@ + + +prout + + +

prout

+ + + diff --git a/docker-swarm/app/Dockerfile b/docker-swarm/app/Dockerfile new file mode 100644 index 0000000..57f3f27 --- /dev/null +++ b/docker-swarm/app/Dockerfile @@ -0,0 +1,7 @@ +FROM php:8.2-apache + +RUN docker-php-ext-install pdo pdo_mysql && \ + docker-php-ext-enable pdo_mysql + +COPY config/000-default.conf /etc/apache2/sites-available/000-default.conf +RUN a2enmod proxy_http headers diff --git a/docker-swarm/app/config/000-default.conf b/docker-swarm/app/config/000-default.conf new file mode 100644 index 0000000..7404ae1 --- /dev/null +++ b/docker-swarm/app/config/000-default.conf @@ -0,0 +1,35 @@ + + # The ServerName directive sets the request scheme, hostname and port that + # the server uses to identify itself. This is used when creating + # redirection URLs. In the context of virtual hosts, the ServerName + # specifies what hostname must appear in the request's Host: header to + # match this virtual host. For the default virtual host (this file) this + # value is not decisive as it is used as a last resort host regardless. + # However, you must set it for any further virtual host explicitly. + #ServerName www.example.com + + ServerAdmin webmaster@localhost + DocumentRoot /var/www/html + + + ProxyPass http://adminer:8080/ + ProxyPassReverse http://adminer:8080/ + RequestHeader add X-Forwarded-Prefix /adminer + + + # Available loglevels: trace8, ..., trace1, debug, info, notice, warn, + # error, crit, alert, emerg. + # It is also possible to configure the loglevel for particular + # modules, e.g. + #LogLevel info ssl:warn + + ErrorLog ${APACHE_LOG_DIR}/error.log + CustomLog ${APACHE_LOG_DIR}/access.log combined + + # For most configuration files from conf-available/, which are + # enabled or disabled at a global level, it is possible to + # include a line for only one particular virtual host. For example the + # following line enables the CGI configuration for this host only + # after it has been globally disabled with "a2disconf". + #Include conf-available/serve-cgi-bin.conf + diff --git a/docker-swarm/app/docker-compose.yml b/docker-swarm/app/docker-compose.yml new file mode 100644 index 0000000..462d32a --- /dev/null +++ b/docker-swarm/app/docker-compose.yml @@ -0,0 +1,47 @@ +# -*- coding: utf-8 mode: yaml -*- vim:sw=2:sts=2:et:ai:si:sta:fenc=utf-8 + +services: + db: + image: mariadb:10 + environment: + MARIADB_ROOT_PASSWORD: admin + MARIADB_DATABASE: mydb + MARIADB_USER: myuser + MARIADB_PASSWORD: pass + volumes: + - data:/var/lib/mysql + - ./initdb:/docker-entrypoint-initdb.d + networks: + - int + deploy: + update_config: + order: stop-first + placement: + constraints: + - node.hostname == sw1 + + adminer: + image: adminer + networks: + - int + + web: + build: . + image: sw1.self:5000/app-web + volumes: + - logs:/var/log/apache2 + - ./public:/var/www/html + networks: + - int + - proxy + deploy: + replicas: 3 + +volumes: + data: + logs: + +networks: + int: + proxy: + external: true diff --git a/docker-swarm/app/initdb/visit.sql b/docker-swarm/app/initdb/visit.sql new file mode 100644 index 0000000..c627fa1 --- /dev/null +++ b/docker-swarm/app/initdb/visit.sql @@ -0,0 +1,7 @@ +-- -*- coding: utf-8 mode: sql -*- vim:sw=4:sts=4:et:ai:si:sta:fenc= + +create table visit ( + id integer primary key auto_increment, + ts timestamp, + url varchar(256) +); diff --git a/docker-swarm/app/public/index.php b/docker-swarm/app/public/index.php new file mode 100644 index 0000000..6fb814b --- /dev/null +++ b/docker-swarm/app/public/index.php @@ -0,0 +1,30 @@ +prepare("insert into visit(ts, url) values (now(), :url)"); +$st->execute([ + "url" => $_SERVER["SCRIPT_NAME"], +]); + +$st = $pdo->query("select count(*) count from visit"); +$count = $st->fetch()["count"]; + +?> + +prout + + +

prout

+

Nombre de visites:

+ + + diff --git a/docker-swarm/app/public/info.php b/docker-swarm/app/public/info.php new file mode 100644 index 0000000..c4837a3 --- /dev/null +++ b/docker-swarm/app/public/info.php @@ -0,0 +1 @@ +