feat: Basic functional project done.

This commit is contained in:
KyMAN 2024-10-12 15:22:40 +02:00
parent 6773f8db8c
commit b3c7fffdf1
19 changed files with 442 additions and 1 deletions

View File

@ -0,0 +1,9 @@
from debian
volume ./git /Projects
volume ./scripts /Scripts
volume ./files /Files
volume ../docker/Nginx/tmp /Nginx
copy install.sh /install.sh
run chmod +x /install.sh
run /install.sh
run rm /install.sh

View File

@ -0,0 +1,17 @@
{
"language" : "espanol",
"print_files_pattern" : "/Python\\/(common.py|Application|Managers|Drivers|Models)/",
"print_types_allowed" : ["unkn", "info", "ok", "warn", "erro", "exce", "test", "note", "help"],
"i18n_show_add_ok_message" : false,
"path_show_load_ok_message" : false,
"http_show_add_ok_message" : false,
"managers_routes_show_add_file_error_message" : true,
"managers_mime_extensions_show_add_ok_message" : false,
"managers_mime_extensions_show_add_extension_ok_message" : false,
"path_show_get_modified_date_ok_message" : false,
"threads_show_add_ok_message" : false,
"managers_routes_show_go_ok_message" : false,
"threads_show_remove_ok_message" : false,
"show_print_types_add_item_ok_message" : false,
"unix_domain_socket_web_server_show_process_request_ok_message" : false
}

View File

@ -0,0 +1,37 @@
{
"servers" : {
"UnixDomainSocketWeb" : {
"driver" : "Drivers.UnixDomainSocketWebServer",
"path" : "/Nginx/anp.sock",
"clients" : 5,
"permissions_acl" : false,
"users" : ["kyman", "www-data"],
"http_version" : "1.1",
"sudo" : false
}
},
"applications" : {
"CDN" : {
"path" : "/Projects/CDN/Python",
"class" : "Application.CDN"
},
"ErrorsManager" : {
"path" : "/Projects/ErrorsManager/Python",
"class" : "Application.ErrorsManager"
},
"WMarkDown" : {
"path" : "/Projects/WMarkDown/Python",
"class" : "Application.WMarkDown"
},
"PythonMapper" : {
"path" : "/Projects/PythonMapper/Python",
"load" : false,
"class" : "Application.PythonMapper"
},
"AnPWeb" : {
"path" : "/Projects/AnP/Python",
"load" : false,
"class" : "Application.AnPWeb"
}
}
}

4
AnPServer/install.sh Normal file
View File

@ -0,0 +1,4 @@
#!/bin/bash
# apt update && apt -y upgrade && apt -y autoremove
apt update
apt -y install python3 git

4
AnPServer/rebuild.sh Executable file
View File

@ -0,0 +1,4 @@
#!/bin/bash
directory=`dirname $(readlink -f "$0")`
[ "$(docker images -q kyman:anp-server 2>/dev/null)" ] && docker image remove kyman:anp-server --force
docker build -f $directory/Dockerfile.debian -t kyman:anp-server $directory --no-cache

59
AnPServer/scripts/entrypoint.sh Executable file
View File

@ -0,0 +1,59 @@
#!/bin/bash
closed=
# rm -R /Projects/*
if [[ "$1" == "1" ]];then
rm -R /Projects/*
fi
[[ "$(cat /etc/passwd|grep kyman)" == "" ]] && useradd -u 1000 -m kyman
[[ "$(cat /etc/passwd|grep www-data)" == "" ]] && useradd -u 33 www-data
build(){
local name=$2
cd /Projects
if [[ ! -d $name ]];then
local group=$1
git clone https://git.k3y.pw/$group/$name
if [[ "$name" == "AnP" ]];then
[[ -d /Projects/$name/Python/Modules ]] || mkdir /Projects/$name/Python/Modules
for module in ErrorsManager WMarkDown;do
ln -s /Projects/$module/Python/$module.py /Projects/$name/Python/Modules/$module.py
done
else
[[ -d /Projects/$name/Python/Abstracts ]] || mkdir /Projects/$name/Python/Abstracts
for file in AnPMap Applications;do
ln -s /Projects/AnP/Python/Abstracts/$file.py /Projects/$name/Python/Abstracts/$file.py
done
fi
fi
}
build KyMAN ErrorsManager
build Whalers WMarkDown
build AnP AnP
build KyMAN PythonMapper
build KyMAN CDN
[[ -f /Projects/AnP/JSON/AnP.py.settings.secrets.json ]] ||
ln -s /Files/AnP.py.settings.secrets.json /Projects/AnP/JSON/AnP.py.settings.secrets.json
[[ -f /Projects/AnP/JSON/AnP.py.settings.server.secrets.json ]] ||
ln -s /Files/AnP.py.settings.server.secrets.json /Projects/AnP/JSON/AnP.py.settings.server.secrets.json
trap "closed=1" INT TERM EXIT
while [[ "$closed" != "1" ]];do
wait || wait
sleep 1
done
# [[ -f /Scripts/stop.sh ]] && source /Scripts/stop.sh

3
AnPServer/scripts/run.sh Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash
cd /Projects/AnP/Tools
./server.py.sh

32
Documentation/espanol.md Normal file
View File

@ -0,0 +1,32 @@
El proyecto **AnPDockerServer** es un pequeño proyecto de muestreo y guía para montar un servidor AnP con Docker, con sus Scripts correspondientes y gestión de dependencias y ficheros locales. El servidor AnP irá puenteado por un servidor Proxy que gestione la salida pública del mismo, al poder ser, mediante un Socket de Dominio Unix (Unix Domain Server o UDS). A medida que vaya desarrollándose dicho proyecto aparecerán nuevas tecnologías y métodos por los que comunicarse mediante puenteo Proxy.
Se usará el Docker Compose para gestionar el conjunto de las herramientas, y cada contenedor será Buildeado a partir de un Script que tendrán cada uno acompañado a su correspondiente Dockerfile, el cual será siempre "rebuild.sh". Las nomenclaturas del Dockerfile no será el estándar *Dockerfile* sino que será continuado por el sistema operativo por el que operará separado de un punto, por lo general como *Dockerfile.debian*.
La subred del Docker Compose será **172.22.0.0/24** por defecto, y todos los contenedores que éste lance será siempre sobre dicha subred.
# Nginx
Nginx es una tecnología Proxy de origen ruso Full Open Source muy extendido. Es cierto que existe una alternativa Full Free Open Source, pero en este caso, se decidió montar sobre la tecnología original.
> Somos conscientes de que ya existe un contenedor público en Docker Hub de Nginx, sin embargo, éste no sigue el patrón de funcionamiento original de Nginx, pese a ser original y propio de los creadores de Nginx, por lo que se decidió crear de 0 un contenedor base Debian con esta tecnología para que éste coincida con la documentación oficial del mismo, pero eso no quita que pueda ser usado de la misma manera el contenedor oficial que los creadores dejaron público.
El servidor Nginx operará directamente sobre la IP **172.22.0.86** y levantará los siguientes puertos:
- **80**: Para las salidas y peticiones HTTP.
- **443**: Para las salidas y peticiones HTTPS.
También compartirá los siguientes directorios:
- **/Projects**, *"/Nginx/projects" en local*: Este directorio se usa para compartir y gestionar desde el anfitrión los ficheros de configuración del propio Nginx.
- **/Certificates**, *"/certificates" en local*: Este directorio contendría los certificados acordes a los distintos dominios que tengamos registrados en el Nginx.
- **/Scripts**, *"/Nginx/scripts" en local*: Este directorio almacena los Scripts para que el OS pueda ejecutar en entorno de ejecución o que el propio usuario habra una nueva terminal mediante "docker exec -it nginx-server bash" y pueda operar de forma más sencilla las diferentes partes que el proyecto toca.
- **/var/log/nginx**, *"/Nginx/logs" en local*: Este será un directorio autocreado que contendrá los Logs del propio Nginx compartidos con el anfitrión para que el usuario tenga acceso a los mismos externamente al contenedor y éstos no se pierdan por cada reinicio o apagado del contenedor.
- **/tmp/pointers**, *"/Nginx/tmp" en local*: Este directorio se automontará en local y sólo contendrá cosas cuando éste sea usado por el propio Nginx, como es el caso de la creación por parte de terceras aplicaciones un archivo de gestión de comunicación de Sockers de Dominio Unix, por ejemplo.
En los proyectos nos encontraremos dos ficheros, los cuales son:
- **/Projects/nginx.80.conf**: El cual está diseñado para funcionar sobre el puerto 80, tanto en escucha como en envío, es decir, por el protocolo HTTP.
- **/Porjects/nginx.443.conf**: El cual está diseñador para funcionar sobre el puerto 443, tanto en escucha como en envío, es decir, por el protocolo HTTP con SSL, es decir, HTTPS. Éste depende plenamente de los certificados, donde tenemos uno de prueba para opera con éste aunque no concuerde con el dominio que está firmando.

8
Nginx/Dockerfile.debian Normal file
View File

@ -0,0 +1,8 @@
from debian
expose 80/tcp
expose 443/tcp
volume ./projects /Projects
volume ./certificates /Certificates
volume ./scripts /Scripts
volume ./logs:/var/log/nginx
volume ./tmp:/tmp/pointers

View File

@ -0,0 +1,34 @@
-----BEGIN CERTIFICATE-----
MIIF9TCCA92gAwIBAgIUPRDqUDcgk39zrxJkR2vfrHq9z50wDQYJKoZIhvcNAQEL
BQAwgYkxCzAJBgNVBAYTAkVTMRAwDgYDVQQIDAdHYWxpY2lhMQ8wDQYDVQQHDAZG
ZXJyb2wxDjAMBgNVBAoMBUt5TUFOMQ4wDAYDVQQLDAVLeU1BTjEVMBMGA1UEAwwM
a3ltYW4uazN5LnB3MSAwHgYJKoZIhvcNAQkBFhEwa3ltYW4wQGdtYWlsLmNvbTAe
Fw0yNDEwMTIxMjEyNDhaFw0yNTEwMT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gbST6NrwoUjHIGtp7tIk8QfdLFRyFshECggEAZ01auOcIGyR+bIxYw7BM
FltATAc4ze/XWZ9z3uHHeSTrmZIw1f7WEJR/H+vQj9Sv/aaD5kvKyOUV7StY9YIw
+SlVfzbEVJmSyoK/w+I/fiazkbHyp+SWYyx2L5ODIFycz3Jf+l5yPjnC2vrrH73U
T7KckbJDJyFeF+9pF4lrudPe9tScSqV8zzsb2gAPnTqdF+eMsINT1XttBVe6j+Ru
+BZj0qYxmBhLKQ9YsnAOjHwn32pjVb047nMo7t24eTnLnTj01wAHYQFKNyyS7Mj6
yhDoqToF8aUES6ejDwba8Qz7onSX1a0XEXO8yg1RxCHPeeC9n4oHptILTk8Es1zw
FQKCAQBOnUV+2DmkQCJzM4kd7D3YgQR3drPIdMBTADedGWCOZwq1BLLRQZsCmFGM
qphVQz1P9eXJYJae9pJ5WYaI1wzK6+Fk3m5JmK+nXjdElHMdt2erhd8smcpOburD
VHbh4WE1Uj9H/iFFemEl7t9+KxaVsmDZgpHXAfwMEp92utRuKJY1C3YuOWQee5Mg
V5cUB8nNsGR4x6L0LpyqMjxbwnkDL9CQeUB3JTesyiyKurCSiaOhvRkxZpxOWI0L
Pd7KMH7NW63Et0wBdpk6u38Oiif3bXB1PLtQmKcqf1bVpJzXf02tY2uJg2yEuhox
RR+gn4ay5Dbpfo4ZIuT2tAwA3RQW
-----END PRIVATE KEY-----

View File

@ -0,0 +1,41 @@
server {
listen 80 default_server;
listen [::]:80 default_server;
access_log /var/log/nginx/default.access.log;
access_log /var/log/nginx/default.error.log;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl default_server;
listen [::]:443 ssl default_server;
ssl_certificate /Certificates/test.crt;
ssl_certificate_key /Certificates/test.key;
access_log /var/log/nginx/default.433.access.log;
error_log /var/log/nginx/default.433.error.log;
location / {
root /Projects/default;
index index.html index.htm;
}
}
server {
listen 443 ssl;
server_name ~^(anp|cdn|errorsmanager|wm(arkdown|d)|pythonmapper)\.local?$;
ssl_certificate /Certificates/test.crt;
ssl_certificate_key /Certificates/test.key;
access_log /var/log/nginx/default.433.access.log;
error_log /var/log/nginx/default.433.error.log;
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $proxy_add_x_forwarded_for;
proxy_pass http://socket_anp/;
}
}
upstream socket_anp {
server unix:/tmp/pointers/anp.sock;
}

View File

@ -0,0 +1,29 @@
server {
listen 80 default_server;
listen [::]:80 default_server;
root /Projects/default;
access_log /var/log/nginx/default.access.log;
access_log /var/log/nginx/default.error.log;
location / {
try_files /index.html = 404;
}
}
server {
listen 80;
server_name ~^(anp|cdn|errorsmanager|wm(arkdown|d)|pythonmapper)\.local?$;
access_log /var/log/nginx/default.80.access.log;
error_log /var/log/nginx/default.80.error.log;
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $proxy_add_x_forwarded_for;
proxy_pass http://socket_anp/;
}
}
upstream socket_anp {
server unix:/tmp/pointers/anp.sock;
}

4
Nginx/rebuild.sh Executable file
View File

@ -0,0 +1,4 @@
#!/bin/bash
directory=`dirname $(readlink -f "$0")`
[ "$(docker images -q kyman:nginx-server 2>/dev/null)" ] && docker image remove kyman:nginx-server --force
docker build -f $directory/Dockerfile.debian -t kyman:nginx-server $directory --no-cache

View File

@ -0,0 +1,25 @@
#!/bin/bash
name=$1
days=$2
if [[ "$name" == "" ]];then
echo -e "[ERRO] I need a name for the new certificate. Use the next example for your command where days is optional and it is 365 (1 year) by default:\n./create_certificate.sh NAME [DAYS]"
else
echo "[INFO] Creating the new certificate '$name'..."
if [[ "$(command -v openssl)" == "" ]];then
echo "[INFO] Installing the 'openssl' command application for create the new certificate."
apt install -y openssl
fi
if [[ "$days" == "" ]];then
days=365
fi
openssl req -newkey rsa:4096 -x509 -sha256 -days $days -nodes -out $name.crt -keyout $name.key &&
echo "[ OK ] The new certificate '$name' was created for $days days. Look for the '$name.crt' and '$name.key' files in this folder." ||
echo "[ERRO] There was any error creating the new certificate '$name'."
fi

42
Nginx/scripts/run.sh Normal file
View File

@ -0,0 +1,42 @@
#!/bin/bash
closed=
mode=80 # 80 || 443 <=> http || https
if [[ "$(command -v nginx)" == "" ]];then
echo "[INFO] Installing Nginx..."
apt update && apt -y upgrade && apt -y autoremove
apt install -y nginx
# chmod +x docker.entrypoint.sh
fi
echo "[INFO] Settings Nginx..."
/etc/init.d/nginx restart
[[ -f /etc/nginx/sites-enabled/default ]] &&
run rm /etc/nginx/sites-enabled/default
for type in available enabled;do
[[ ! -f /etc/nginx/sites-$type/nginx.$mode.conf ]] &&
[[ -f /Projects/nginx.$mode.conf ]] &&
ln -s /Projects/nginx.$mode.conf /etc/nginx/sites-$type/nginx.$mode.conf
done
echo "[ OK ] Nginx installet and set fully."
echo "[INFO] Restarting Nginx..."
/etc/init.d/nginx restart
trap "closed=1" INT TERM EXIT
while [[ "$closed" != "1" ]];do
wait || wait
sleep 1
done
echo "[INFO] Stopping Nginx..."
/etc/init.d/nginx stop

View File

@ -1,3 +1,5 @@
# AnPDockerServer
A Single project for deploy the AnP Server in Docker. In the first, it was deployed by Nginx, but it was change with new technologies, without removed old.
[![Español](https://cdn.local/images/flags/espanol.svg)](Documentation/espanol.md)

38
docker-compose.yml Normal file
View File

@ -0,0 +1,38 @@
services:
anp_server:
image: kyman:anp-server
container_name: anp-server
volumes:
- ./AnPServer/git:/Projects
- ./AnPServer/scripts:/Scripts
- ./AnPServer/files:/Files
- ./Nginx/tmp:/Nginx
networks:
dev-network-tests:
ipv4_address: 172.22.0.190
command: /Scripts/entrypoint.sh
nginx_server:
image: kyman:nginx-server
container_name: nginx-server
ports:
- 80:80/tcp
- 443:443/tcp
volumes:
- ./Nginx/projects:/Projects
- ./certificates:/Certificates
- ./Nginx/scripts:/Scripts
- ./Nginx/logs:/var/log/nginx
- ./Nginx/tmp:/tmp/pointers
networks:
dev-network-tests:
ipv4_address: 172.22.0.86
command: /Scripts/run.sh
networks:
dev-network-tests:
driver: bridge
ipam:
config:
- subnet: 172.22.0.0/24

1
version Normal file
View File

@ -0,0 +1 @@
0.0.1.0