merged duplicate repository

This commit is contained in:
giomba 2021-05-10 22:45:33 +02:00
commit 360df7f146
5 changed files with 84 additions and 0 deletions

21
cgi-python/Dockerfile Normal file
View File

@ -0,0 +1,21 @@
FROM alpine:latest
EXPOSE 80
COPY install.sh /install.sh
COPY entrypoint.sh /entrypoint.sh
RUN mkdir -p /srv/cfg
RUN apk add bash
RUN apk add git
RUN apk add thttpd
RUN apk add python3
RUN apk add py-pip
# tutta questa merda per compilare delle dipendenze pip di caldav, ma io dico
RUN apk add gcc py3-wheel libxml2-dev libxslt-dev libc-dev python3-dev
COPY thttpd.conf /srv/thttpd.conf
RUN bash install.sh
ENTRYPOINT ["/entrypoint.sh"]

11
cgi-python/README.md Normal file
View File

@ -0,0 +1,11 @@
# cgi-python
## Istruzioni per aggiungere una nuova applicazione CGI Python
1. Assicurarsi che siano rispettate le seguenti convenzioni:
* script CGI nominato come `main.py`;
* eventuale presenza di un `requirements.txt` con la lista di dipendenze pip;
* eventuale presenza di una cartella `conf` dove lo script CGI deve caricare la configurazione da un file `conf.custom.ini`;
1. Procurarsi l'URL del repository git su cui è versionato il progetto
1. Inserire l'URL in `install.sh` accondandolo nell'array di repository.
1. Committare, pushare e chiedere al capofficina di aggiornare il container.

2
cgi-python/entrypoint.sh Executable file
View File

@ -0,0 +1,2 @@
#!/bin/bash
thttpd -D -C /srv/thttpd.conf

45
cgi-python/install.sh Executable file
View File

@ -0,0 +1,45 @@
#!/bin/bash
function die {
echo -e "Qualcosa è andato storto"
exit -1
}
DEPLOY_DIR="/srv/cgi"
CFG_DIR="/srv/cfg"
mkdir -p $DEPLOY_DIR
mkdir -p $CFG_DIR
# Lista dei repository CGI
REPO[0]="https://git.golem.linux.it/golem/zerocalcare.git"
REPO[1]="https://git.golem.linux.it/golem/tpdf.git"
# ... aggiungi qui altri repository, basta che rispettino le specifiche
# descritte nel readme
cd $DEPLOY_DIR
# Che bello il bash e la sua sintassi creativa, no?
for url in ${REPO[*]}; do
PRJ_DIR=$(basename "$url" .git)
git clone $url
test $? -eq 0 || die
pushd $PRJ_DIR
# Linka la configurazione nel sottovolume
if [ -d conf ]; then
ln -s $CFG_DIR/$PRJ_DIR.conf.ini conf/conf.custom.ini
test $? -eq 0 || die
fi
if [ -f requirements.txt ]; then
pip install -r requirements.txt
test $? -eq 0 || die
fi
popd
done
exit 0

5
cgi-python/thttpd.conf Normal file
View File

@ -0,0 +1,5 @@
dir=/srv/cgi
port=80
charset=utf-8
cgipat=**/main.py
user=root