importation initiale

This commit is contained in:
Jephté Clain 2025-02-10 07:08:21 +04:00
commit 1fcedfa03f
23 changed files with 389 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
.~lock*#
.*.swp

View File

@ -0,0 +1,4 @@
FROM php:8.2-apache
RUN docker-php-ext-install pdo pdo_mysql && \
docker-php-ext-enable pdo_mysql

View File

@ -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:

View File

@ -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)
);

View File

@ -0,0 +1,30 @@
<?php
$pdo = new PDO("mysql:host=db;dbname=mydb", "myuser", "pass");
$st = $pdo->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"];
?><html>
<head>
<title>prout</title>
</head>
<body>
<h1>prout</h1>
<p>Nombre de visites: <?=$count?></p>
<ul>
<?php
foreach ($_SERVER as $key => $value) {
if (is_array($value)) $value = var_export($value, true);
echo "<li>$key = $value</li>\n";
}
?>
</ul>
</body>
</html>

View File

@ -0,0 +1 @@
<?php phpinfo();

View File

@ -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

View File

@ -0,0 +1,35 @@
<VirtualHost *:80>
# 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
<Location /adminer/>
ProxyPass http://adminer:8080/
ProxyPassReverse http://adminer:8080/
RequestHeader add X-Forwarded-Prefix /adminer
</Location>
# 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
</VirtualHost>

View File

@ -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:

View File

@ -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)
);

View File

@ -0,0 +1,30 @@
<?php
$pdo = new PDO("mysql:host=db;dbname=mydb", "myuser", "pass");
$st = $pdo->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"];
?><html>
<head>
<title>prout</title>
</head>
<body>
<h1>prout</h1>
<p>Nombre de visites: <?=$count?></p>
<ul>
<?php
foreach ($_SERVER as $key => $value) {
if (is_array($value)) $value = var_export($value, true);
echo "<li>$key = $value</li>\n";
}
?>
</ul>
</body>
</html>

View File

@ -0,0 +1 @@
<?php phpinfo();

View File

@ -0,0 +1,3 @@
FROM php:8.2-apache
COPY public/ /var/www/html/

View File

@ -0,0 +1,18 @@
<html>
<head>
<title>prout</title>
</head>
<body>
<h1>prout</h1>
<ul>
<?php
foreach ($_SERVER as $key => $value) {
if (is_array($value)) $value = var_export($value, true);
echo "<li>$key = $value</li>\n";
}
?>
</ul>
</body>
</html>

View File

@ -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

View File

@ -0,0 +1,35 @@
<VirtualHost *:80>
# 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
<Location /adminer/>
ProxyPass http://adminer:8080/
ProxyPassReverse http://adminer:8080/
RequestHeader add X-Forwarded-Prefix /adminer
</Location>
# 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
</VirtualHost>

View File

@ -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

View File

@ -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)
);

View File

@ -0,0 +1,30 @@
<?php
$pdo = new PDO("mysql:host=db;dbname=mydb", "myuser", "pass");
$st = $pdo->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"];
?><html>
<head>
<title>prout</title>
</head>
<body>
<h1>prout</h1>
<p>Nombre de visites: <?=$count?></p>
<ul>
<?php
foreach ($_SERVER as $key => $value) {
if (is_array($value)) $value = var_export($value, true);
echo "<li>$key = $value</li>\n";
}
?>
</ul>
</body>
</html>

View File

@ -0,0 +1 @@
<?php phpinfo();

View File

@ -0,0 +1,15 @@
# -*- coding: utf-8 mode: yaml -*- vim:sw=2:sts=2:et:ai:si:sta:fenc=utf-8
services:
main:
image: nginxproxy/nginx-proxy
volumes:
- /var/run/docker.sock:/var/run/docker.sock
network:
- proxy
ports:
- 80:80
networks:
proxy:
external: true

View File

@ -0,0 +1,13 @@
# -*- coding: utf-8 mode: yaml -*- vim:sw=2:sts=2:et:ai:si:sta:fenc=utf-8
services:
main:
image: registry:2
volumes:
- data:/var/lib/registry
ports:
- 5000:5000
restart: unless-stopped
volumes:
data:

View File

@ -0,0 +1,15 @@
# -*- coding: utf-8 mode: yaml -*- vim:sw=2:sts=2:et:ai:si:sta:fenc=utf-8
services:
main:
image: dockersamples/visualizer:stable
ports:
- 9000:8080
volumes:
- /var/run/docker.sock:/var/run/docker.sock
#deploy:
# placement:
# constraints:
# - node.hostname == sw1
# #- node.platform.os == linux
# #- node.role == manager